thefollower Posted August 25, 2007 Share Posted August 25, 2007 How do i construct a query which would do something like this: search in tablename and find all the records with houseID which is the same as HouseID of housetablename ? Im only used to using the UserID session in queries so ive not done something like that before ^ ? Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/ Share on other sites More sharing options...
samoht Posted August 25, 2007 Share Posted August 25, 2007 It seems like you just need to: <?php SELECT * FROM tablename, housetablename WHERE houseID = HouseID What else? Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/#findComment-333852 Share on other sites More sharing options...
pocobueno1388 Posted August 25, 2007 Share Posted August 25, 2007 It seems like you just need to: <?php SELECT * FROM tablename, housetablename WHERE houseID = HouseID What else? Wouldn't it be: SELECT * FROM tablename t, housetablename h WHERE t.houseID = h.HouseID I'm no expert in MySQL, so they may do the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/#findComment-333858 Share on other sites More sharing options...
phpSensei Posted August 25, 2007 Share Posted August 25, 2007 its the same thing, just different ways of writing it... Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/#findComment-333862 Share on other sites More sharing options...
thefollower Posted August 25, 2007 Author Share Posted August 25, 2007 which one is best to use though :S Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/#findComment-333865 Share on other sites More sharing options...
phpSensei Posted August 25, 2007 Share Posted August 25, 2007 <?php $result=mysql_query("SELECT * FROM housetablename WHERE houseID = HouseID"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/#findComment-333873 Share on other sites More sharing options...
AV1611 Posted August 25, 2007 Share Posted August 25, 2007 aliasing the table name takes a little longer but when you start doing joins you will be glad you learned to use them i.e. SELECT DISTINCT a.name,a.ip,b.name FROM onlineip AS a Inner Join onlineip AS b ON a.ip = b.ip WHERE a.name NOT LIKE b.name AND a.ip NOT LIKE '' AND a.name NOT LIKE 'Recruit' AND b.name NOT LIKE 'Recruit' order by a.name Quote Link to comment https://forums.phpfreaks.com/topic/66637-query-comparison/#findComment-333878 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.