Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

There are two columns in a MySQL table: SUBJECT and YEAR.

I want to generate an alphanumeric unique number which holds the concatenated data from SUBJECT and YEAR.

How can I do this? Is it possible to use a simple operator like +?

1 Answer

0 votes
by (119k points)

You can use the following SQL query to concatenate SUBJECT and YEAR columns in a table:

SELECT CONCAT ('SUBJECT', '  ', 'YEAR') as new_column from Table_Name

The second argument is to create space between SUBJECT and YEAR columns after concatenating.

I recommend going through this SQL tutorial to learn more about CONCAT() function.

Related questions

0 votes
1 answer
asked Dec 31, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Jul 29, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Jul 18, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Jul 5, 2019 in SQL by Tech4ever (20.3k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...