php, mysql, html, css, js, c#, java, c++ coder

Mysql ile Çapraz olarak tablo güncellemesi yapma

Şubat 27, 2010 | In: MySQL

UPDATE uyeler AS s , uyelerYedek AS q
SET s.dogumTarihi = q.yas
where s.id = q.id

gibi yaparak eski / yedek tablonuzdaki verileri yeni tablonuzdakilerle değiştirebilirsiniz
ansızın gece nin 5:30 unde uyeler tablosunun dogumTarihi kolonunun veritipini değiştiğinizde (örneğin varchar dan date ) tüm verilerin silineeğini unutmayınız yedeğiniz varsa eski kolondaki verileri alabilirsiniz :)
veya substring_index(q.yas,’.',-1) as yil gibi gibi tarihleri parse edipte aktarabilirsiniz.

1
2
3
4
5
6
7
8
9
10
11
 UPDATE uyeler AS s , uyelerYedek AS q
SET
s.dogumTarihi = concat(
SUBSTRING_INDEX( q.yas , '.', -1 )
,'-',
substring_index(SUBSTRING_INDEX( q.yas , '.', 2),'.',-1)
,'-',
SUBSTRING_INDEX( q.yas , '.', 1 )
)

WHERE s.id = q.id
Paylaş ve HalayÇek: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Technorati
  • Digg
  • del.icio.us
  • YahooMyWeb
  • Taggly
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • IndiaGram
  • Internetmedia
  • Netscape
  • Reddit
  • Scoopeo
  • StumbleUpon

Comment Form

Takvim

Temmuz 2010
Pts Sal Çar Per Cum Cts Paz
« Haz    
 1234
567891011
12131415161718
19202122232425
262728293031