I have a table with a column labeled state. I want to select all the rows (and columns) from that table and display their information. However, I want the state column to display “CA” if they are from California and “Not from CA” if they are from anywhere else. What is the command to swap a value.
Here is what I have so far, I just need the swap command. Not even sure what to search for on Google for this so I’m hoping to find the answer here.
SELECT VendorName, VendorState
FROM Vendors
WHERE VendorState='CA'
UNION
SELECT VendorName, VendorState
FROM Vendors
WHERE VendorState<>'CA'
ORDER BY VendorName
I came to the specific answer I wanted by SQLMenaces query format so he gets his answer accepted. But this is what I wanted for anyone else who might stumble on this question.
SELECT VendorName, VendorState
FROM Vendors
WHERE VendorState='CA'
UNION
SELECT VendorName, 'Outside CA'
FROM Vendors
WHERE VendorState<>'CA'
ORDER BY VendorName
try
and just to show you how you would swap in your query, you can do