Problem joining 2 tables

Results 1 to 2 of 2

Thread: Problem joining 2 tables

  1. #1
    Join Date
    Dec 1969

    Default Problem joining 2 tables

    Please help...<BR><BR>I&#039;m not a newbie to SQL but it&#039;s been a while since i touched it. I need to join 2 DB which are not quite in sync. The primary key of each database is slightly different. The only difference is actually a "0" in front of every statement in the second DB (example, the first DB would read "A3456" in its key column, and the 2nd would read "0A3456".<BR><BR>Since i don&#039;t have access to modify either of the DB, how can i write a SQL "WHERE" statement that will link the 2 DB properly ??<BR><BR>Please Help.<BR>Regards,<BR>Etienne St-Cyr, Montréal, Qc

  2. #2
    Join Date
    Dec 1969

    Default Nothing says...

    ...that you even *HAVE* to link two tables by a PK/FK relationship.<BR><BR>You could link them by (say) person&#039;s name to foods available in some restaurant. [You&#039;d likely only find matches for people named "Frankfurter" or "Mignon", but it would work.]<BR><BR>So:<BR> SELECT ..<BR> FROM table1, table2<BR> WHERE table1.key = (&#039;0&#039; + table2.key)<BR>Or:<BR> SELECT ..<BR> FROM table1, table2<BR> WHERE Substring( table1.key, 2, 999 ) = table2.key<BR>Or even:<BR> SELECT ..<BR> FROM table1, table2<BR> WHERE table2.key LIKE &#039;%&#039; + table1.key<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts