0

I have 20 tables with 2 fields, id and name description

Colors
id  name
1 black
2 blue 
...

Sizes
id name  
1 100
2 105
...

Now i have the main table with 21 fields

Main table `shoes`

id Colors Sizes style ...
1    2     24     11

I have a form post with 20 text inputs (one for each kind of feature, color, size..) what i want is to learn the most efficient way to look at 20 features tables (Select id from colors where name='blue') and get the id value, if not exists, create it ( insert into colors (name) values (pink) ) and then get the id ,once I have the 20 values ​​will do the big insert into the main field

TimWolla
  • 31,849
  • 8
  • 63
  • 96
Colas
  • 157
  • 1
  • 2
  • 12

1 Answers1

0

Use the INSERT ... ON DUPLICATE KEY UPDATE syntax.

FtDRbwLXw6
  • 27,774
  • 13
  • 70
  • 107