[SOLVED]Dual tableselect problems

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

[SOLVED]Dual tableselect problems

Post by evilmonkey »

This query is giving me problems, I wonder if someone can tell mewhat I'm doing wrong.

Code: Select all

mysql_query("SELECT * FROM `users` AS users, `favourites` AS favourites WHERE
			`favourites.user_id` = $this->userid AND `favourites.type` = '$type'
			ORDER BY `users.popularity` DESC");
The error that I get is: Unknown column 'favourites.user_id' in 'where clause'.

Help appreciated. Thanks. :)
Last edited by evilmonkey on Sun Dec 18, 2005 5:05 pm, edited 1 time in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Is there a column named user_id in the favourites table?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Yes. :?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Iseem to have finxed it. The problem was with the ` character around favourties.user_id. If someone could elaborate on when those ticks areneeded, I'd really appreciate it.
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

evilmonkey wrote:Iseem to have finxed it. The problem was with the ` character around favourties.user_id. If someone could elaborate on when those ticks areneeded, I'd really appreciate it.
viewtopic.php?t=41318
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

to sum it up

Code: Select all

`tablename`.`columnname`
not

Code: Select all

`tablename.columname`
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Yes...that would make sense. Thanks, problem solved. :D
Post Reply