Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 04-02-2007, 08:25 PM Joining tables help
Experienced Talker

Posts: 46
Trades: 0
I'm having trouble with a query and hopefully someone can help me.

I have two tables in my database that I'm trying to join, so I can retrieve the art from the database but by what the user has stored.

art
artid thumbnail_url
1 images/pic.jpg
2 images/smile.jpg


users_art
userid artid
1 1
1 2

as you can tell, artid is the same and I'm trying to join them in my query. I came up with this:
PHP Code:
$query "SELECT art.thumbnail, users_art.userid FROM art, users_art WHERE art.artid = users_art.artid AND users_art.userid='$temp_id'"
$temp_id is the user's ID, so when they login it can pull the results by the user. I get no results, so I assume something is wrong.
bld44 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-03-2007, 04:37 AM Re: Joining tables help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you have the ID variable surrounded by quotes
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-03-2007, 05:11 PM Re: Joining tables help
Experienced Talker

Posts: 46
Trades: 0
Right- but I think I did it without the whole AND.... and it still didn't work. Is that query correct for what I'm trying to do here?
bld44 is offline
Reply With Quote
View Public Profile
 
Old 04-03-2007, 07:15 PM Re: Joining tables help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Or a join

Code:
SELECT art.thumbnail_url, users_art.userid FROM users_art INNER JOIN  art ON users_art.artid = art.artid WHERE users_art.userid = $temp_id;
Should work ok (Not tested BTW)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-03-2007, 07:36 PM Re: Joining tables help
Experienced Talker

Posts: 46
Trades: 0
Ok, that works! Thank you very much.
bld44 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Joining tables help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.56990 seconds with 12 queries