shahzad429 Posted May 21, 2013 Share Posted May 21, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/278234-mysql-query-help/ Share on other sites More sharing options...
cyberRobot Posted May 21, 2013 Share Posted May 21, 2013 Maybe this will help: http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php Quote Link to comment https://forums.phpfreaks.com/topic/278234-mysql-query-help/#findComment-1431354 Share on other sites More sharing options...
theverychap Posted May 21, 2013 Share Posted May 21, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/278234-mysql-query-help/#findComment-1431369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.