Website Development Prices

Website Development Prices

Wednesday, October 21, 2015

Upotreba podupita umesto privremene tabele (Using subqueries instead of temporary tables)

Podupit mozete navesti u odredbi from spoljasnjeg upita. 

Ako vam je potrebno da pretrazujete rezultate podupita, koji u tom slucaju igra ulogu privremene tabele.

Primer:

select * from
(select sifrakupca, ime from kupci where grad='Split')
as split_kupci;

Ovaj fajl sacuvajte kao podupiti.sql.

1. Pokrenite XAMPP. Kliknite na Admin u liniji MySQL-a ili ukucajte u address bar http://localhost/phpmyadmin/

2. Sa leve strane izaberite bazu podataka volimmotore, a sa desne izberite karticu SQL.
3. Ubacite ovaj kod i kliknite dugme "Go".






Objasnjenje:

Obratite paznju na podupit u odredbi from. Neposredno iza zagrade koja zatvara podupit morate zadati alijas za rezultate podupita. Te rezultate zatim mozete obradjivati u spoljasnjem upitu na isti nacin kao i svaku drugu tabelu. 

Subquery you can specify in the clause FROM the outer query.

If you need to search results of subquery, which in this case plays the role of temporary tables.

Example:

SELECT * FROM
(SELECT customerid, name from customers where city='Split')
AS split_customers;

Save this file as subqueries.sql.

1. Start XAMPP. Click on the Admin in line MySQL or type in the address bar 
http://localhost/phpmyadmin/

2. From the left select the database lovebikes, and on the right select the SQL tab.
3. Insert this code and click "Go".




Explanation:


Note the subquery on clause FROM. Shortly after the brackets enclosing the subquery you must specify an alias for the results of the subquery. These results you can process into the outer query in the same way as any other table.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.