question

willingnable avatar image
willingnable asked

Query to return data based on an ID that match substring in another column.

I have data in one column (Notes) that contains Customer ID's in some records (not all). So I need to create a query that says if customer_id matches ANY customer ID in the database, display Name for that customer.

sql query
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
irsbcgp avatar image
irsbcgp answered

I have data in one column (Notes) that contains Customer ID's in some records (not all).

- What is the name of the table?

So I need to create a query that says if customer_id matches ANY customer ID in the database,

Any customer ID in which table, or are you saying the customer ID can exist in any table in the database? From what you say it sounds like the second option

display Name for that customer.

What do you want to happen if the customer name exists in more than one table?

It's very difficult to give you an answer because you haven't given enough detail. Try and think about explaining what you want to someone who has never seen your database and doesn't understand what process the database supports. Probably the best way is to supply a sample script creating tables and data and then explaining what you expect as a result. It might help if you explained why a customer ID would exist in a column called 'Notes' (and can different customer IDs be present in the same row?)

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.