Sub_select problem

Поиск
Список
Период
Сортировка
От Bernie Huang
Тема Sub_select problem
Дата
Msg-id 3957EE8F.3B145049@ec.gc.ca
обсуждение исходный текст
Список pgsql-sql
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

Вложения

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Gary MacMinn"
Дата:
Сообщение: Re: Merging two columns into one
Следующее
От: "K Parker"
Дата:
Сообщение: Re: unique sequences