Jump to content

new problem using select - select multiple colums from join tables


botcha

Recommended Posts

 

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

 

Link to comment
Share on other sites

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

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.