pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bernie Huang <bernie.huang@ec.gc.ca>
To: PGSQL-SQL <pgsql-sql@postgresql.org>
To: PHP Database <php-db@lists.php.net>
Subject: Sub_select problem
Date: Mon, 26 Jun 2000 17:00:15 -0700
Message-ID: <3957EE8F.3B145049@ec.gc.ca> (raw)

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

Attachments:

bernie.huang.vcf (text/x-vcard, 314B) download 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

Message-ID: <3957EE8F.3B145049@ec.gc.ca>
Permalink:  ../3957EE8F.3B145049@ec.gc.ca/
Also on:    postgresql.org/message-id/3957EE8F.3B145049@ec.gc.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: bernie.huang@ec.gc.ca, php-db@lists.php.net
  Subject: Re: Sub_select problem
  In-Reply-To: <3957EE8F.3B145049@ec.gc.ca>
  References: <3957EE8F.3B145049@ec.gc.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox