Received: from sandtstudent.pyr.ec.gc.ca (fwvan1.pyr.ec.gc.ca [199.212.20.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e5R01v137716 for ; Mon, 26 Jun 2000 20:01:58 -0400 (EDT) Received: from ec.gc.ca (IDENT:huangb@sandtstudent [131.235.150.249]) by sandtstudent.pyr.ec.gc.ca (8.9.3/8.9.3) with ESMTP id RAA29224; Mon, 26 Jun 2000 17:00:18 -0700 Message-ID: <3957EE8F.3B145049@ec.gc.ca> Date: Mon, 26 Jun 2000 17:00:15 -0700 From: Bernie Huang Organization: Environment Canada X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 To: PGSQL-SQL , PHP Database Subject: Sub_select problem Content-Type: multipart/mixed; boundary="------------3299249F04514ED7878FE39E" X-Archive-Number: 200006/234 This is a multi-part message in MIME format. --------------3299249F04514ED7878FE39E Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Good day, everyone, I have 2 tables and 1 datafile as following: vehicle_tb ----------- v_id int4 primary key display_id int4 year text make text model text ... vehicle_borrow_log -------------------- employee_id int4 (foreign key to emp_tb) v_id int4 (foreign key to vehicle_tb) borrow_time timestamp return_time timestamp ... datafile.gnu ( a text file) --------------------------- # Date Display_id 2000-XX-XX 1 2000-xx-xx 1 2000-XX-XX 2 2000-xx-xx 2 2000-XX-XX 1 2000-xx-xx 1 ... What I want to do is to fetch the display_id in datafile using PHP (by the way, this part is done). And then use that display_id to get the borrow_time and return time in vehicle_borrow_log. So, I used this sub-select SQL, but it doesn't seem to be working. SELECT v_id, borrow_time, return_time FROM vehicle_borrow_log vbl WHERE (SELECT equip_id FROM vehicle_tb vtb WHERE vtb.v_id=vbl.v_id AND display_id=$id_from_datafile_let_say_it_is_2); Could anyone please help? Thanks! - Bernie --------------3299249F04514ED7878FE39E Content-Type: text/x-vcard; charset=iso-8859-15; name="bernie.huang.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Bernie Huang Content-Disposition: attachment; filename="bernie.huang.vcf" begin:vcard n:Huang;Bernie tel;fax:(604)664-9195 tel;work:(604)664-9172 x-mozilla-html:TRUE org:Environment Canada;Standards and Technology Services adr:;;700-1200 West 73 Ave.;Vancouver;BC;V6P 6H9;Canada version:2.1 email;internet:bernie.huang@ec.gc.ca title:Programmer x-mozilla-cpt:;0 fn:Bernie Huang end:vcard --------------3299249F04514ED7878FE39E--