0

i have some doubt about my mysql query and wanted to discuss here. i have three tables tablea,tableb and tablec

 tablea 

id    someid
1       434
2       352
3       329

tableb

id     otherid     cid
1      434         54        
2      6934         2453
3      434         24
4      9548        67

here otherid is appearing more than one time and also appearing once in tablea

tablec

id       otherid     cid  
1        all deleted row details of tableb will be stored here

what i am doing

selecting one random row from tablec and matching someid with otherid and as i want to store the tableb details in tablec so first i am performing insert into for tablec and then deleting the tableb row it seems to be correct but in tableb more than one rows are there so deleting is not an issue as i can directly match with someid and delete all rows from tableb but in tablec i have to insert the cid values also so if i will do as ihave explained it will work fine ?any suggestions are welcome

raviloves
  • 197
  • 1
  • 3
  • 12
  • have you looked into any database triggers? – DRapp Dec 23 '12 at 18:52
  • @DRapp no i have bot checked – raviloves Dec 23 '12 at 18:54
  • Could you try rephrasing the question a bit? I sincerely dont understand what you're asking or trying to achieve. – Joachim Isaksson Dec 23 '12 at 18:55
  • @JoachimIsaksson from tablec i have one id which i am searching in tableb and when i find that id in tableb i will be interested in inserting tableb values in tablec and then delete that row from tableb – raviloves Dec 23 '12 at 18:57
  • Don't do this. See [Is storing a comma separated list in a database column really that bad?](http://stackoverflow.com/a/3653574) – eggyal Dec 23 '12 at 19:38
  • @eggyal nothing is comma seperated.everything is in different column – raviloves Dec 24 '12 at 13:55
  • Erm. Okay. Could you explain `tablec.cid` a little better, then? It appeared to me from your question that that was a single column that contained all of the `cid` from `tableb` having the same `otherid`? – eggyal Dec 24 '12 at 14:12
  • @eggyal its like friendship. cid is users id who has requested you to become your friend – raviloves Dec 24 '12 at 14:21
  • @eggyal 100% correct but not to mehe can request to any other usrrs – raviloves Dec 24 '12 at 14:45

0 Answers0