tutorial 3: sql

query with operator

SELECT firstName + '  ' + lastName AS [full name]
FROM memberDetails
WHERE city='yogyakarta';
SELECT filmName
FROM films
WHERE yearReleased <= 1990;

operator AND

SELECT filmName, lastName, street, city, state, zipCode
FROM memberDetails
WHERE dateOfJoining >= '2004-01-01' AND dateOfJoining <= '2005-03-01';
SELECT firstName, lastName
FROM memberDetails
WHERE dateOfBirth <= '1990-05-05' AND state='jakarta';

operator OR

SELECT state, dateOfJoining
FROM memberDetails
WHERE state='new state' OR state='golden state'
AND dateOfJoining >= '2005-01-01';

 

SELECT firstName, lastName, city, DateofBirth
FROM memberDetails
WHERE (city = 'Townsite' OR city='bigcity')
AND
      (DateofBirth >= '1989-05-29' OR DateofBirth <= '1945-08-17');

operator NOT

SELECT firstName
FROM memberDetails
WHERE NOT STATE='golden state';

operator BETWEEN

SELECT filmName, yearReleased, Rating, AvailableonDVD
FROM Films
WHERE (Rating BETWEEN 2 AND 4)
AND
      (AvailableonDVD = 'y');

operator LIKE

SELECT lastName
FROM memberDetails
WHERE lastName LIKE 'J%';

 

SELECT lastName
FROM memberDetails
WHERE lastName LIKE 'D_s';
SELECT lastName
FROM memberDetails
WHERE lastName NOT LIKE 'J%';

operatot IN

SELECT filmName, yearReleased, Rating
FROM Films
WHERE yearReleased in (1967,1977,1987)
AND
RATING in (4,5);

operator ORDER BY

SELECT yearReleased
FROM Films
ORDER BY yearReleased DESC;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s