Hello, i m now working on converting PHP script from mysqli to SQL (for Azure) and came across a big issue “FIND_IN_SET” i did read allot and as much as i understood there are no alternative for SQL
Might be better posted in the database section, as it’s nothing to do with the PHP language.
I’ve only briefly read about the function, but it seems most useful when storing multiple values in a single column, something I’ve tried to avoid doing.
I don’t believe you are going to find any single function equivalent for that. Storing multiple vales in a single column should be avoided in a relational database. Normalizing a poorly built database can be very expensive and time consuming affaire. Depending on how many places that function is used a band aid type approach might be creating a table or view that replicates the data in s normalized fashion and altering the queries where find in is set is used to use that table or view instead. This might come with a performance cost.
Sounds like you may be happy and functional (working) now. If you are still using “IN” with success and are still using this code (“implode” like above), be sure to not forget to add/concatenated quotes to the outside values. Implode will only put string ‘,’ in-between values but not on the outside. So be careful that first and last value in array also properly included in the IN() clause string you build.
I was under the impression the column in db has multiple values but now I see I was wrong. So IN should work fine. There is a difference though because find in set is an exact string match and IN is conditional based on matching a single value in a set. It would probably be best to see a screen capture of the data you’re working with in the table.