Page 1 of 1

Pulling rows from two tables in the same database...

Posted: Mon Nov 07, 2011 1:53 pm
by orbdrums
I can't seem to get a query to work properly. What I'm trying to do seems simple enough but not simple enough for me I guess. I want to pull fields (login_date, login_time) from a table called login_hist. I also want to pull fields (logout_date, logout_time) from a table called logout_hist WHERE a common field in both tables (member_id) equals the currently logged in member. Here is the code that is returning the query error:

Code: Select all

Invalid query: Column 'member_id' in where clause is ambiguous Whole query: SELECT * FROM login_hist,logout_hist WHERE member_id = 4 ORDER BY `login_date` DESC, `login_time` DESC
And here is the error:

Invalid query: Column 'member_id' in where clause is ambiguous Whole query: SELECT * FROM login_hist,logout_hist WHERE member_id = 4 ORDER BY `login_date` DESC, `login_time` DESC

Any help would be greatly appreciated.
C

Re: Pulling rows from two tables in the same database...

Posted: Mon Nov 07, 2011 2:01 pm
by mikosiko
Do not duplicate your posts... a clear answer was already given to you here
http://www.devnetwork.net/viewtopic.php ... e742337fb2

Re: Pulling rows from two tables in the same database...

Posted: Mon Nov 07, 2011 2:14 pm
by orbdrums
I wouldn't duplicate posts if they weren't moved. Someone moved my post and I couldn't find it so I posted it again. If another one of my posts is moved I will repost another one. Simple as that.

Re: Pulling rows from two tables in the same database...

Posted: Mon Nov 07, 2011 2:28 pm
by mikeashfield
orbdrums wrote:I wouldn't duplicate posts if they weren't moved. Someone moved my post and I couldn't find it so I posted it again. If another one of my posts is moved I will repost another one. Simple as that.

Your posts (for future reference).

Re: Pulling rows from two tables in the same database...

Posted: Mon Nov 07, 2011 3:06 pm
by pickle
Locking thread.