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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on a multiple table query

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
0
0
US
Hello all,

I'm having trouble on a select statement I'm executing with two tables. Basically I'm trying to count how many instances an id number appears in a table. The first and most important query I need to execute to do this looks like this:
Code:
$session_part_query = pg_Query($conn, "SELECT DISTINCT t0.part_id FROM sess_panelists t0, participants t1 
			WHERE (t0.part_id = t1.part_id) ORDER BY t1.part_last ASC");

I end up getting this error:

Code:
pg_query() query failed: ERROR: For SELECT DISTINCT, ORDER BY expressions must appear in target list in ... line 45

I've never run into this kind of error before. Can someone please tell me what's going on?

Thanks,
Jisoo22
 
add t1.part to your select

like
Code:
SELECT DISTINCT t0.part, t1.part_last FROM....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top