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

Easy SQL Query

Status
Not open for further replies.

AXtechie

Technical User
Sep 19, 2006
2
US
I speak Unix, but forget SQL queries, could you please help.... me write the code

I will run this from a unix command line, from a remote computer so I need to connect to the database too.

There is one database called DB and two tables called T1 and T2. I am interested in using some data from T1 to query against T2


@ARRAY = SELECT id FROM T1 (read each entry of the column 'id' into an array)

Foreach $entry (@ARRAY) (loop through each entry)
SELECT $entry
FROM T2
WHERE column = '1'
 

OS?
DBMS?
[ponder]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Right.... I guess that would help.
MySQL running on Redhat Linux.
If I write a script I will run it from a remote Redhat terminal. Or I can connect to the database and run direct SQL commands
 
Code:
select T2.somecolumn
  from T2
inner
  join T1
    on T1.id = T2.somecolumn  
 where T2.column = 1

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top