0

I have some fields in a table Employee, with fields

empID,empName,empAddress,empCity...

And all the values of empAddress field contains like "ADR 250 Candy", "ADR 330 Simla, "ADR 220 Karty" and so on.

I want a query to list otr the address without the word 'ADR'.

Eg: I want to display the address like "250 Candy", "330 Simla", "220 Karty" ....

Please help me on this

0

2 Answers 2

2

Try

SELECT SUBSTR(E.empAddress, 4) AS 'Address' FROM Employee E

If you want to skip the space character also replace SUBSTR(E.empAddress, 4) with SUBSTR(E.empAddress, 5)

Sign up to request clarification or add additional context in comments.

1 Comment

The Query gives the correct answer. But while using the above(first one) i am getting the field name as SUBSTR(E.empAddress,4)
0

try this :

SELECT EmpAddress = REPLACE(E.empAddress, 'ADR ', '') 
FROM Employee E

3 Comments

"try this" is not adequate explanation for an answer. Please explain why this answers the question. Code-only solutions are considered poor content on Stack Overflow.
Hi, could you please add some explanation to your code? This popped up in the review queue, as code-only answers tend to.
well the REPLACE function does the normal replace in string job and it's a built-in SQL Server function, so i thought maybe it's self-explanatory and just put it sloppy out there. however, we have supposedly an Employee table and we're gonna replace the string ADDR with empty string in empAddress field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.