Jump to content
Sign in to follow this  
sh4m_1

[mysql] Camne nak update 3 table sekali gus...

Recommended Posts

tiga2 table ni ade book_code and book_title

tp aku nak update book_title = shamhensem tp book_code adalah 1001
setiap table dalam book_code adalah unique (xde no sama)....

camne nak wat..??

Share this post


Link to post
Share on other sites
asal cam pelik je table2 ko wat ni... da book code tu je yg unique, nape nak sumbat book title dkt table2 lain gak...

satu table da cukup tuk store book_code + book_title + author + etc...

table2 lain letak book_code as Foreign Key(FK) pon cukup ler... so ko update book_title dkt satu table tu je, takyah pening2 nak update dkt sume table, jenuh nak update... ::lol::

Share this post


Link to post
Share on other sites
tumpang lalu..

tengkubasri,
aku xtau soklan aku betul atau x. kalau pakai engine MyISAM x bole letak Fk kan? kalau InnoDB baru bole letak FK kan? aku pakai phpmyadmin, tp x pandai guna command..

sham,
kau pakai engine aper?
er.. betul ke cara aku tanya nih? hehehe.. ::icon_bounce::

Share this post


Link to post
Share on other sites
memang lari skit la erd....

nak wat camne.. tgh2 coding... skali org ni mintak macam tu....

aku wat la sperate.. nak search 3 3 table ni, ok aku pakai UNION method...

tp nak update je mengom skit...

ade ke syntax lain utk update 3 3 table ni....

Share this post


Link to post
Share on other sites
titanbullet wrote:tumpang lalu..

tengkubasri,
aku xtau soklan aku betul atau x. kalau pakai engine MyISAM x bole letak Fk kan? kalau InnoDB baru bole letak FK kan? aku pakai phpmyadmin, tp x pandai guna command..

sham,
kau pakai engine aper?
er.. betul ke cara aku tanya nih? hehehe.. ::icon_bounce::


tuk FK mmg kene pakai innoDb. myIsam tak blh. kena pandai godek skit. rasanya takyah guna command tuk enablekan InnoDB tu.

Share this post


Link to post
Share on other sites
OK, aku dah jumpa statement nk update data dlm 3 table skaligus (dah test dh):
Code:

UPDATE <table1>,<table2>,<table3> set <table1>.book_title="shamhensem",<table2>.book_title="shamhensem",<table3>.book_title="shamhensem" where <table1>.book_code="1001" and <table2>.book_code="1001" and <table3>.book_code="1001";

Slamat mencuba ::icon_smile::

Share this post


Link to post
Share on other sites
sh4m wrote:camne ko leh dpt..??

Konsep "Try An Error" dalam PHPmyadmin / mysql command prompt dan pertolongan drpd pakcik Google ::icon_smile::

Aku ingat fungsi UPDATE x bleh staraf fungsi INSERT dan SELECT utk multiple data atau table, tapi bila tgk formatnye sama je, aku try2 jugak.
Tapi aku blum jumpa lagi format sesuai untuk fungsi DROP atau TRUNCATE dan CREATE, sbb stakat nih x bleh pakai utk multiple table / database.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...