help on SQL
June 30, 2006 12:47 PM
Subscribe
Need some help with combining SQL queries. New to SQL - some programming back ground.
I have two very simple SQL statements, I am VERY new to SQL so I am trying to "learn as I go."
I have two queries I would like to combine to save time:
select rtf_seq from enc_documentation
where enc_seq =
select * from text_document
where text_document_seq =
for update
As a note:
text_documentation seq = rtf_seq (just different names on different tables).
Thank you
posted by lutzla23 to computers & internet (9 comments total)
1 user marked this as a favorite
select * from enc_documentation, text_document
where text_documentation_seq = rtf_seq AND enc_seq = whatever_value_you_are_querying_for
This "joins" the two tables based on text_documentation_seq = rtf_seq. It will return all fields from both tables, for all rows where these two fields are equal AND enc_seq equals the desired value.
Note that it is good practice to keep the same field name for fields that exist in multiple tables.
posted by utsutsu at 12:58 PM on June 30, 2006