0
In which case should I use dot(.) operator and IN clause ?
3 Réponses
+ 1
when you use a table alias you will need to use dot notation.
a table alias is for instance.
select * from schools s1
now if you ever need to use the schools table you can use s1.
this is particularly useful when using joins
+ 1
you use the in syntax when you either want to specify a range of values such as
select * from schools where name in ('schoolname','schoolname','schoolname')
or you can have a sub query such as
select * from schools where ID in (select schoolid from schoolregions where region ='west')
0
Dot is used as follows eg.:
select tbl1.name, tbl2.address from tbl1 join tbl2 on tbl2.id = tbl1.id where tbl1.id = 123
also can be used to select from other database like
db1.tabl1
syntax <optional database>.<optional table>.field
If you'r operating with one db and table no need to use the database or table name.
IN operator eg.
select name from tbl1 where id id(123,456,789)
is much nicer to use than alternative with OR
select name from tbl1 where id = 123 or id = 456 or id = 789
hope this helps. Please correct me, but I think dot is not called operator at all. Don't know the right term though...