logo
down
shadow

How to search for a comma-separated string in a database table in mySQL


How to search for a comma-separated string in a database table in mySQL

By : user2952985
Date : November 19 2020, 03:59 PM
around this issue How to search for a comma-separated string in a database table in mySQL. , Work like this i hope this is your requirement
code :
select * from table where field_name like '%$fieldname%' 


Share : facebook icon twitter icon
search a specific string from mysql database from a number of words stored separated by comma

search a specific string from mysql database from a number of words stored separated by comma


By : Shayek Ibne Ali
Date : March 29 2020, 07:55 AM
With these it helps i am trying to make a search function in which i require to search the string which is passed through the ajax call. suppose the word is Sound & Lighting and i want to search this in the mysql database table where number of words are stored separated by comma for eg the words stored as bike,light,Sound & Lighting,roses i want the word Sound & Lighting to be searched from those number of words separated by comma which is stored in database table as a value . I tired using item_name like '%$search%' but this also didnt helped much. Any help on this? , If I understand your question correctly, I think you need this:
code :
SELECT *
FROM yourtable
WHERE CONCAT(',', col, ',') LIKE CONCAT('%,', 'Sound & Lighting', ',%')
SELECT *
FROM yourtable
WHERE FIND_IN_SET('Sound & Lighting', col);
Search comma separated string using LIKE in mysql

Search comma separated string using LIKE in mysql


By : RaphaSP
Date : March 29 2020, 07:55 AM
this one helps. I have a table with 3 columns something like below, , You should use REGEXP.
Try this query:
code :
SELECT * FROM experts 
    WHERE expert_in REGEXP '[[:<:]]1[[:>:]]';
How to search from comma separated string in comma separated column mysql

How to search from comma separated string in comma separated column mysql


By : Jake Beaube
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I am working on a project where I have to code for job filters. In this when I filters for salaries it sends salary id's in array like: , Use it like below let me know if it works
code :
$values=array("1","2","3");

foreach($values as $val)
{
    $query="Select * from table_name where  FIND_IN_SET('".$val."',column_name)";
$result=mysql_query($query);
$data=mysql_fetch_array($result);
$dbval[]=$data['column_name'];

}

print_r($dbval);
search comma separated values from column contains comma separated string mysql

search comma separated values from column contains comma separated string mysql


By : uladescamps
Date : March 29 2020, 07:55 AM
Any of those help Like Jens has pointed out in the comments, it is highly recommended to normalize your schema.
If you wish to continue with string and comma separated values, you should then be looking at complex regex matching (which I leave it to you to explore).
code :
CREATE TABLE IF NOT EXISTS `tbl` (
  `id` int(6) unsigned NOT NULL,
  `interest`  JSON DEFAULT NULL,
  `status` int(1) NOT NULL,
  PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;

INSERT INTO `tbl` (`id`, `interest`,`status`) VALUES
  (1, '[1,2,3,4]',1),
  (2, '[1,2]',1),
  (3, '[3]',1);
select id from tbl where JSON_CONTAINS( interest ,'[1,2]')
select id from tbl where JSON_CONTAINS( interest ,'[3,4]');
...
Need search a value from database from comma separated string

Need search a value from database from comma separated string


By : Arun krishna
Date : March 29 2020, 07:55 AM
This might help you You can use FIND_IN_SET e.g.
SELECT * FROM images WHERE FIND_IN_SET(161, check_values) > 0
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org