SkyRanger Posted November 22, 2006 Share Posted November 22, 2006 I am trying to pull info from two tables. I am not very good at the join command. I have tried everything I know with no luck which brings me here. can somebody help.This is what I need.2 Tables: client and addservI am trying to select * and display data from both client and addserv where username='Ausernamehere' Quote Link to comment Share on other sites More sharing options...
impulse() Posted November 22, 2006 Share Posted November 22, 2006 Hello.Try:[code]SELECT *FROM client, addservWHERE somethingFromClient = somethingFromAddservAND username = '$username'[/code]Hope that helps, Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted November 23, 2006 Author Share Posted November 23, 2006 Thanks, this is what I currently have:[code]$result = mysql_query( "SELECT * FROM client, addserve WHERE client.username = addserve.username AND username = '$username'") or die( "Unable to select database");[/code]What I want to do is: pull out all the info from the client table plus all of the info from addserve where the username in both equals a clients username. ie: username='$username' Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted November 23, 2006 Author Share Posted November 23, 2006 I keep getting: Unable to select databaseWhen I select from 1 table no problems, when I try to get data from 2 tables, that is where I get lost. That example that was provided I copied and pasted, but never worked. I am a NOOB at php/mysql but i then changed it to client.username = addserve.username which is probably not right. Can anybody give me a hand here? Quote Link to comment Share on other sites More sharing options...
mansuang Posted November 23, 2006 Share Posted November 23, 2006 Could you show some example data in your database? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted November 23, 2006 Author Share Posted November 23, 2006 Not sure what you would be looking for but sure:Table: clientid: 1name: John SmithUsername: jsmithpassword: a1b3#fAddress: 123 My StreetTable: addserve:username: jsmithserv: Package 1Display Would be:Full Name: John SmithUsername: jsmithpassword: a1b3#fPackage Ordered: Package 1 Quote Link to comment Share on other sites More sharing options...
mansuang Posted November 23, 2006 Share Posted November 23, 2006 [quote author=SkyRanger link=topic=115975.msg472610#msg472610 date=1164292362]Thanks, this is what I currently have:[code]$result = mysql_query( "SELECT * FROM client, addserve WHERE client.username = addserve.username AND username = '$username'") or die( "Unable to select database");[/code]What I want to do is: pull out all the info from the client table plus all of the info from addserve where the username in both equals a clients username. ie: username='$username'[/quote]Try to put table_name.username For example:--------------------$result = mysql_query( "SELECT * FROM client, addserve WHERE client.username = addserve.username AND [color=red]client.[/color]username = '$username'") or die( "Unable to select database");--------------------Because column 'username' in where clause is ambiguous Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted November 23, 2006 Author Share Posted November 23, 2006 Awsome, got it to work, Thank you very much Quote Link to comment 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.