Sql question. I need to return a value to the left of the '-'. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Sql question. I need to return a value to the left of the '-'.

Return a value to the left of the '-' if its there. Example 20048 would return 20048 and 20048-34 would return 20048.

2nd Nov 2018, 1:56 PM
Julie Ann
Julie Ann - avatar
1 Answer
+ 1
Assuming you used varchar (or its variant) for storing the number, I suggest you to add the DBMS involved in "Relevant Tags", surely you understand, different DBMS has different ways/syntax for handling text/string alike data. My idea for the issue however, is to use a function that searches and returns the position of a certain character within a string data, if you can find one suitable for your DBMS, you'll get your solution.
2nd Nov 2018, 5:36 PM
Ipang