AndyUK
1
Can’t seem to find the answer to this anywhere.
How can I do this type of query in MySQL…
SELECT a, b, c FROM table;
for each result returned {
if a = 1 then ( insert into table2 (a) values (a) )
else then ( insert into table3 (a) values (a) )
}
The INSERT INTO SELECT syntax will do it…You’d just need two, one where a = 1, and one where it doesn’t.
INSERT INTO table2 (col1, col2, ..., colN)
SELECT col1, col2, ..., colN
FROM table1
WHERE col2 = 'x';
AndyUK
3
That was just a high-level example of what I am trying to do
And I was just giving you a high level example on how to handle it without a loop
AndyUK
5
Haha, that product hierarchy is driving me mad.
I think I’m going to have to give up and ask someone on fiverr to do it
system
Closed
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.