Jump to content

Mysql query help


shahzad429

Recommended Posts

I have two tables

CREATE TABLE `pricedata` (
  `TableID` int(11) NOT NULL AUTO_INCREMENT,
  `AgentName` int(10) DEFAULT NULL,
  `VechicleName` int(10) DEFAULT NULL,
  `DestinationName` int(10) DEFAULT NULL,
  `FromDA` float DEFAULT '0',
  `FromAA` float DEFAULT '0',
  `FromSA` float DEFAULT '0',
  `FromRA` float DEFAULT '0',
  `UserID` int(10) DEFAULT NULL,
  PRIMARY KEY (`TableID`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1;
CREATE TABLE `vehicles` (
  `TableID` int(11) NOT NULL AUTO_INCREMENT,
  `VechicleName` varchar(255) DEFAULT NULL,
  `VehiclesTypeName` int(10) DEFAULT NULL,
  `MoreInfo` longblob,
  `Pic1` varchar(255) DEFAULT NULL,
  `Facilities` varchar(1000) DEFAULT NULL,
  `MaxPass` varchar(255) DEFAULT NULL,
  `MaxSuit` varchar(255) DEFAULT NULL,
  `GolfBag` varchar(255) DEFAULT NULL,
  `ExtraBag` varchar(255) DEFAULT NULL,
  `ChildBooster` varchar(255) DEFAULT NULL,
  `InfantSeat` varchar(255) DEFAULT NULL,
  `WheelChair` varchar(255) DEFAULT NULL,
  `Bicycle` varchar(255) DEFAULT NULL,
  `ExtraStop` varchar(255) DEFAULT NULL,
  `UserID` int(10) DEFAULT NULL,
  PRIMARY KEY (`TableID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

what i am doing right now is using below query

"select * from pricedata where DestinationName='1' group by AgentName ,VechicleName"

 

but now i am stuck because now clients wants to show result based on VehiclesTypeName which is in my second table.

so how i can display the result where DestinationName=1, VehiclesTypeName=3 and MaxPass<=4?

 

maybe we can do it my mysql join or left or right join i am weak in mysql if anyone can help me please.

 

Thanks,

Shahzad

 

Link to comment
Share on other sites

Does pricedata.VechicleName (int) contain vehicles.TableID? if so, something like

SELECT pd.yourfields FROM pricedata pd LEFT JOIN vehicles v ON pd.VechicleName = v.TableID WHERE yourwhereclause...

may get you on the right track.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.