Very basic MySQL user and trying to obtain information about support contracts.
We have a column called products which lists all the products on an order (not separated out into individual rows) So order 1000 might have "products' = PROD1|PROD2|SUPPORT.
What I want to do is create a new column and make it true/false and have a lookup or formula (i.e. If "products" contains "SUPPORT" or "PS12" or "PS24 then update "new_column" with "true" else default "false"
Can this be done in MySQL?
MySQL can probably be used for more or less the same things as most other RDBMS. I'm in no way an expert and this site is dedicated to answering questions about SQL Server. But since this is a not-so-complex query, I'll try anyway :)
Why do you want to update a new column based on which products is in a column? If you want to use the new column to check which orders have a "SUPPORT" in them, the information is already on each row. Creating a new column is therefore not necessary.
So I won't give an answer how to update the table, only how to query it to get that BIT a part of the result. This is T-SQL, but I think MySQL can handle variables as well
Or if you mean you want to see if any of a number of hardcoded products are in the column, you could do:
answered Feb 16, 2011 at 12:02 AM
Try case statement
answered Feb 15, 2011 at 10:06 PM