Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with LEFT JOIN

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
I can't seem to get this to work! It does display records, however they are all the same person.

I have two tables

users / friendlist

friendlist:

fid | fidon | fidlisted
1 3 4
2 3 5
3 3 6
4 3 7


users:

uid | uname
4 jason
5 bob
6 eric
7 smith


I want to display every friend's name from the table friendlist with a fidon id=3




Code:
	sql = "SELECT "_
		& "friendlist.fidon," _
		& "friendlist.fidlisted," _
		& "users.uid," _
		& "users.uname" _
		& " FROM friendlist LEFT JOIN users on friendlist.fidlisted=users.uid WHERE friendlist.fidon=" & fuid


Thanks in advance.
 
Are you passing it the '3'?

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
yes

fuid is the variable 3

friendlist.fidon=" & fuid


the odd thing is, i tried running the below query in a mysql gui, and it selects correctly, but when i do it in the browser, its only showing 1 name?

im confused.

Code:
SELECT friendlist.fidon,friendlist.fidlisted,users.uid,users.uname FROM friendlist LEFT JOIN users on friendlist.fidlisted=users.uid WHERE friendlist.fidon=3
 
if your query works fine in mysql, and doesn't work in your scripting language (php?), then guess where the problem is

:)

r937.com | rudy.ca
 
You are probably not using a WHILE or FOR loop to display your results properly in PHP. Take a look in the php.net manual for mysql_fetch_row, mysql_fetch_array, mysql_fetch_assoc depdending on which one you are using and make sure you follow the example accordingly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top