botcha Posted January 20, 2012 Share Posted January 20, 2012 hirealimo.com.au/code1.php this works as i want it: SELECT * FROM price INNER JOIN vehicle USING (vehicleID) WHERE vehicle.passengers >= 1 AND price.townID = 1 AND price.eventID = 1 but apparelty selecting * is not a good thing???? but if I do this: SELECT priceID, price FROM price INNER JOIN vehicle....etc it works but i lose the info from the vehicle table. but how do i make this work: SELECT priceID, price, type, description, passengers FROM price INNER JOIN vehicle....etc so that i am specifiying which colums from which tables to query?? thanks Quote Link to comment https://forums.phpfreaks.com/topic/255406-new-problem-using-select-select-multiple-colums-from-join-tables/ Share on other sites More sharing options...
gizmola Posted January 20, 2012 Share Posted January 20, 2012 You prefix the column with the tablename (tablename.column). You only need to do this when you have to resolve the case where you have the same column name in more than one of the joined tables, so that the sql engine can not determine which . I should probably add that most people use aliases to make this less painful. The kitchen sink answer for using the wildcard '*' is this: SELECT v.*, p.* FROM price p INNER JOIN vehicle v ..... Quote Link to comment https://forums.phpfreaks.com/topic/255406-new-problem-using-select-select-multiple-colums-from-join-tables/#findComment-1309497 Share on other sites More sharing options...
botcha Posted January 22, 2012 Author Share Posted January 22, 2012 so is tablename.* ok to use? or can that be hacked easily? when i specified each tablename.column to retrieve i got errors Quote Link to comment https://forums.phpfreaks.com/topic/255406-new-problem-using-select-select-multiple-colums-from-join-tables/#findComment-1310128 Share on other sites More sharing options...
gizmola Posted January 25, 2012 Share Posted January 25, 2012 Yes, tablename.* is fine to use. Quote Link to comment https://forums.phpfreaks.com/topic/255406-new-problem-using-select-select-multiple-colums-from-join-tables/#findComment-1310918 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.