0

I was given a database that is a little weird, but I am not able to change it. There is a field that is set as an array but holds ids that I need to access in where clauses. Here is the field set up:

TABLE: PROMOS
promo_id   |    contract_ids
-----------------------------
 1               23,34,54
 2               13,34,55
 3               20,30

I need to do an sql query to get all promo_ids where contract id = 34

mysql_query("SELECT promo_id FROM Promos WHERE contract_ids = '34'

Is there a way to do this?? Thanks for any help!

1 Answer 1

3
SELECT promo_id FROM Promos 
WHERE FIND_IN_SET(34, contract_ids) > 0

See FIND_IN_SET doc

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

Comments

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.