I have a table with columns:
JOB_NUM, HM_PH, BUS_PH, CALL1ST
Where the job_num
is a unique number
And the HM_PH
, BUS_PH
, and CALL1ST
columns are 10 digit phone numbers
So using the order of columns above, sample data would look like:
JOB_NUM, HM_PH, BUS_PH, CALL1ST
------------------------------------
12345, 4025557848, 9165897588, 7518884455
10101, 8887776655, 8667416895, 5558884446
What I want to produce is 2 columns.
JOB_NUM, PHONE
Where the job_num is listed next to every phone number such as:
JOB_NUM PHONE
---------------------
12345 4025557848
12345 9165897588
12345 7518884455
10101 8887776655
10101 8667416895
10101 5558884446
Where do I start?
You need a UNION (if you want to remove duplicate rows) or UNION ALL (if you want to keep duplicate rows):
SELECT JOB_NUM, HM_PH AS PHONE FROM yourtable
UNION
SELECT JOB_NUM, BUS_PH FROM yourtable
UNION
SELECT JOB_NUM, CALL1ST FROM yourtable
ORDER BY JOB_NUM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With