[thelist] An SQL query about null and =

john at johnallsopp.co.uk john at johnallsopp.co.uk
Thu Jan 20 10:16:41 CST 2005


Thanks for your responses btw, and I must have missed it yesterday
although I thought I'd watched out for it hard enough not to have to
check the archives. I shoulda checked, sorry.

> The "a.field1 = b.field1 and a.field2 = b.field1" part would indicate
> that
> a.field1 must equal a.field2.  So, unless they matched you would get
> back no
> results.

Would it really? Coo. What I'm trying to get is, well, let's imagine
it's a database of international flights containing a from country and
a to country. The a table holds the flight record and wants to look up
two country codes to get the full country name. a.field1 is, say, US,
a.field2 is, say, UK, and b.field 1 is the country code in the country
table b, so by linking them I'll be able to reach b.field2 which is,
say, the country name.

I want, therefore, two links to the country table. If "a.field1 =
b.field1 and a.field2 = b.field1" means that a.field1=a.field2 then
obviously that's where my problem is.

I won't get much chance to try out your suggestions till next week,
but I'll report back when I do :-)

Best regards
John


More information about the thelist mailing list