Skip to content
Advertisement

Can’t Insert into seperate column while using two select statements

TABLE:

NAME : Jance C hiatt, Sam, Brook, Newyork, London ADDRESS : NULL,NULL,NULL,NULL

NewYork and London should be address column but it is showing on Name itself

Here address is not coming at the separate column of database. Kindly tell me what issue I am facing

Advertisement

Answer

Each insert statement creates new rows, so you cannot expect your queries to automagically align related values on the same row.

I suspect that you have an EAV model that looks like that:

And you want to pivot it in the target table like so:

You can do this in a single statement, using conditional aggregation:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement