Click to See Complete Forum and Search --> : Following a foreign key?


Verdagon
12-04-2009, 07:53 PM
Hey everyone, I think I have a simple question. I have table A, which has a foreign key field whichB that references B's "id" field.

Table A:
whichB int references B(id)

Table B:
id int primary key
numGizmos int;

is there a way to do this?
select * from A a where a.whichB.numGizmos = 4;

basically an inlined lookup. I remember seeing it somewhere but I cant get it to work and for the life of me I can't find anything on google; I tried searching "lookup", "reference", "follow", but the terms just aren't specific enough.

Anyone know how to do this?

- Evan

Webnerd
12-05-2009, 08:54 AM
select * from A inner join B on B.id = A.whichB where B.numGizmos = 4

Verdagon
12-05-2009, 03:47 PM
So theres no way to do it with the syntax I described?

ssystems
12-05-2009, 05:02 PM
So theres no way to do it with the syntax I described?

No.

database.schema.table.column


Some db engine even make schema and database the same. If you ever found the link you said that was able to do it the way you mentioned earlier kindly let us know as I was kinda interested. :)