Jump to content
php.lv forumi

Subselekti


JazMan

Recommended Posts

Sakot ar kuru My SQL versiju var izmantot sub selektus

 

piem

 

"delete from ratings where wallpaperid in (select wallpaperid from wallpaper where galleryid = $gallid)"

19102[/snapback]

Subqueries Add Advanced Querying Capabilities

 

MySQL Version 4.1 will include support for SQL subqueries, also called subselects or nested queries, a powerful feature that lets users search complex data with ease and efficiency.

http://www.mysql.com/news-and-events/press...se_2003_07.html

Link to comment
Share on other sites

Tam kverijam jau nevajag subselektu!

DELETE ratings 
USING wallpaper
WHERE 
 wallpaper.wallpaperid = ratings.wallpaperid AND 
 wallpaper.galleryid = $gallid

19107[/snapback]

 

hmm, shitaadu delete versiju liidz shim nebiju izmantojis. kaadreiz iespeejams noderees. thanx :)

Link to comment
Share on other sites

Tam kverijam jau nevajag subselektu!

DELETE ratings 
USING wallpaper
WHERE 
 wallpaper.wallpaperid = ratings.wallpaperid AND 
 wallpaper.galleryid = $gallid

19107[/snapback]

tieshi taa :)

apmeeram 50-80% gadijumu var izmantot shadu pierakstu pat aizvietojot

3 un vairaak iekseejos subselectus :)

papildus vienai un tai pashai tabulai var pieskirt dazaadus nosaukumus un

izmantot taas kaa divas dazaadas tabulas :)

P.S. teiksim kad vajag selekteet no tabulas ailes kaadu kaudziiti datu no tiem

atlasiit vel dalju un tad tikai dabuut gala rez (teoretiski 2 iekseejie subselekti)...

Link to comment
Share on other sites

Varēji vismaz patiekt, kas nestrādā! (mysql_error).

Pamēģini šādi, laikam aizmirsu FROM uzlikt:

DELETE FROM ratings
USING wallpaper
WHERE
wallpaper.wallpaperid = ratings.wallpaperid AND
wallpaper.galleryid = $gallid

(USING vietā var lietot arī FROM keywordu)

Link to comment
Share on other sites

ahh, nu pareiz, tur ar tabulu vajdzēj :)

Šis jau ļoti normāls veids. Bez subselektiem daudzkur var iztikt, tikai labi jāpārzin JOIN'u veidošana, tad daudz lietas var izdarīt (nu bet protams ne visas, kuras ar subselektiem).

Link to comment
Share on other sites

×
×
  • Create New...