PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 29, 2022

[FIXED] how to select based on comma separated values in column

 August 29, 2022     csv, mysql, select, tags     No comments   

Issue

In my table, one of the column has comma separated values. I would like to select the entry based on one or two values if found in that column like

select * from table where tags contains ('ec2' or 'associate')

or contains multiple values

select * from table where tags contains 's3' and 'rds'

What is the right query?

enter image description here


Solution

You can use the in-built find_in_set function.

find_in_set('s3',tags) > 0 and find_in_set('rds',tags) > 0


Answered By - Vamsi Prabhala
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing