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
https://forums.phpfreaks.com/topic/278234-mysql-query-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.