" /> Password <br /><input type="password" name="passwd" id="passwd" class="inputbox" size="18" alt="password" />
PDF Note

Синтаксис SQL

1
2
3
4
SELECT column_name(s)
FROM table_name1
 JOIN table_name2
ON =table_name2.column_name

- Note: это тоже что и JOIN.

Пример SQL

There is a table "Persons":

P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

O_Id OrderNo P_Id
1 77895 3
2 44678 3
3 22456 1
4 24562 1
5 34764 15

For this we use this query:

1
2
3
4
5
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
 JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName

Query Result:

LastName FirstName OrderNo
Hansen Ola 22456
Hansen Ola 24562
Pettersen Kari 77895
Pettersen Kari 44678

Comments

 
+11 #1 Dinesh 2010-06-25 17:42 Good example. Easy to identify.
Thanx.
Quote
 
 
+15 #2 student 2010-08-09 20:46 Thanks for the article, it is very easy and clear! Quote
 
 
0 #3 Irina 2010-10-20 09:31 Thank you for your life)) Very useful information, sorry no vozmozhnoti immediately potrenerovatsya ... Quote
 
 
-2 #4 nekulin 2010-12-29 09:46 And he can not work with odnakovymi tables?
SELECT cat,(SELECT COUNT(*) FROM t t ON cat.id = t.id) FROM t
error
Not unique table/alias: 't'
Quote
 
 
0 #5 Piotr 2011-03-31 14:57 Thank you for your very clear explanation - really helped. Greetings from Polish:) Quote
 
 
-3 #6 FilBV 2011-04-28 15:27 is a complex task which neither can not seem to solve:
Example: the table "Persons" add two more field "Date" and "Opis_OrderNo", in the "Opis_OrderNo" is filled with text that is owned by OrderNo table "Orders" (a single cell "OrderNo" can belong to multiple cells "Opis_OrderNo", task:
assigned to each cell "OrderNo" table "Orders" on the last time value in the "Opis_OrderNo" table "Persons"
Quote
 
 
+3 #7 fibi 2012-02-23 20:22 Quote
 
 
0 #8 zur4ik 2012-03-21 14:47
Quote
 
 
0 #9 Дмитрий 2012-05-12 20:43



true or false




or



Quote
 

Authorization

Nice Ajax Poll

Which one of my extensions is the best?

Statistics

Advertisement