Artem Risukhin
Artem Risukhin

Reputation: 11

Selecting equal fields from two tables

I am trying to select fields "session_id" with the same value from two tables. My query is the following

SELECT landingpages1988.session_id 
FROM [30032015.landingpages1988], [30032015.exitpages1988] 
WHERE 30032015.landingpages1988.session_id=30032015.exitpages1988.session_id

I get this error:

Error: Encountered "" at line 3, column 44

Could you please assist in correcting?

Upvotes: 1

Views: 110

Answers (1)

Pentium10
Pentium10

Reputation: 207893

The comma operator in FROM line it means union, and not join.

You could run something like:

SELECT t1.select_column
FROM [table1] t1
join [table2] t2
join each on t1.join_column=t2.join_column
WHERE t1.equal_column=t2.equal_column

Update

 SELECT session_id
FROM [30032015.landingpages1988]
WHERE session_id NOT IN (SELECT session_id FROM [30032015.exitpages1988])

Upvotes: 1

Related Questions