Jump to content

Recommended Posts

Hi ,

I try to get data from tehree tables.

any reason why this does not work?

 

(All the php variables are OK)

 

Thanks!

 

 

 

"

SELECT

users.name,

users.phone,

users.email,

 

user_books.bookTitle,

user_books.bookPrice,

 

user_hats.color,

user_hats.pattern

 

FROM users, user_books, user_hats

 

WHERE

      users.login = '$login'

AND users.password = '$pw'

AND user_books.user_id = '$userID'

AND user_hats.user_id = '$userID'

 

";

Link to comment
https://forums.phpfreaks.com/topic/48399-how-to-select-data-from-3-tables/
Share on other sites

Thanks but I can't get it to work.

its working with two tables:

 

"

SELECT

users.name,

users.phone,

users.email,

 

user_books.bookTitle,

user_books.bookPrice,

 

 

FROM users, user_books, user_hats

 

WHERE

users.login = '$login'

AND users.password = '$pw'

AND user_books.user_id = '$userID'

 

";

Better yet, use proper JOIN syntax:

 

SELECT 
users.name, 
users.phone, 
users.email, 

user_books.bookTitle, 
user_books.bookPrice, 

  
FROM users
INNER JOIN user_books ON (users.user_id = user_books.user_id) 
INNER JOIN user_hats ON (users.user_id = user_hats.user_id) 

WHERE 
   users.login = '$login'    
AND users.password = '$pw' 
AND user_books.user_id = '$userID'

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.