Topic: SQL query for two tables (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=27998" title="Pages that link to Topic: SQL query for two tables (Page 1 of 1)" rel="nofollow" >Topic: SQL query for two tables <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-26-2006 17:50

Here is what I have for the database :

tasks

    id (auto incremented)

    owner

    created



users

    id (auto incremented)

    fullname

    email



In the "tasks" table the owner field is the same as the id in the "users" table.

What I need to be able to do, is to query the tasks table and pull the fullname from the users table that matches the owner field from tasks and id from users.

Make sense?

Right now I can query the tasks table and pull the owner field but it is an integer. So I need to match that number to the ID field in the users table and then pull the fullname out to display.

Thanks in advance!

Later,

C:\



(Edited by CPrompt on 05-26-2006 17:53)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-26-2006 17:58

Select users.fullname from users where tasks.owner = users.id AND (other logic to get the right user)



.:[ Never resist a perfect moment ]:.

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-26-2006 18:05

thanks bit, but I was actually doing about that same thing and your's and mine gave this error :

quote:

#1109 - Unknown table 'tasks' in where clause



I know the table is there because the program is working and I can query just that table

Later,

C:\

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 05-26-2006 18:31

Can you show us exactly what the code was that you were using?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-26-2006 18:38

oh I did miss somethnig

Select users.fullname from users,tasks where tasks.owner = users.id AND (other logic to get the right user)

My SQL is actually a bit rusty.



.:[ Never resist a perfect moment ]:.

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-26-2006 19:39

ah...that did the trick. Much appreciated guys!

Later,

C:\

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 05-27-2006 13:56

the concept in question is known as a mysql->join by the way



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu