+ 4
I can't understand this IN concept. Can anyone explain it clearly please?
13 odpowiedzi
+ 14
IN is for selecting multiple values in WHERE clause.
Say you want to select people from the cities London and Berlin.
SELECT name, address FROM cities
WHERE city IN ('London', 'Berlin');
This will then see if the city value is IN the array of values that we provided.
You are looking IN an array.
Hope this helps.
+ 6
it works like an OR-logical operator.
also you can write your statement in this way:
SELECT name, address
FROM cities
WHERE city = 'London'
OR city = 'Berlin';
But we programmer are a little bit lazy. So it is easier to work with the IN-operator.
+ 6
IN allows to use comma(",") instead of multiple OR. So you can put "IN (X,Y,Z)" instead of "X OR Y OR Z", getting much more structured and short code.
+ 5
To extend Nathans answer:
Another use case is where you use it together with a subquery. The following query allows you to get all rows and columns from People that live in Boston and New York without joining the City table or knowing their Ids.
SELECT *
FROM People as t1
WHERE t1.city_id in (SELECT id FROM city WHERE name in("Boston", "New York") );
+ 2
Simply it means that the particular value is present or not
+ 1
in is simply put as the easiest way in testing the condition OR without the repetition of OR over and over
+ 1
IN is almost OR function with using comma
0
grate answer and clear
0
basically, it reduces the lines of coding .
see, if u r using "or " then u have to write or for every instance but if u use IN SO, U can simply put your search in one bracket separated by commas.
0
IN is OR function. can pergorm OR without using multiple time. Just using comma
0
Please let me know which languages are required to be database administrator?
0
in case you want to find in the WHERE condition any of the following values, you can use IN(value1, value2, value3, ect) and the result sill be finding any and all records that meet any of thd values(it would be like using an or for the same conditon multiple times)
0
Instead of using OR you can use IN using the parenthesis which will shorten the code