31303

How to get row of table in which column contains some value.?

Question:

I have TBL_STD_FIELD_VALUE table, in that FLD_USER_IDS column is present. It's datatype is varchar(255). I am storing email ids separated by ',' in that column.

Below is FLD_USER_IDS column values.

<img alt="Query one" class="b-lazy" data-src="https://i.stack.imgur.com/0hY0l.png" data-original="https://i.stack.imgur.com/0hY0l.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

I want to retrieve rows, in which FLD_USER_IDS column contains <strong>'akshay_goel2013@isb.gappspilot.info'</strong> entry.

Below is my sql query

select fieldValues.FLD_USER_IDS from TBL_STD_FIELD_VALUE as fieldValues where 'akshay_goel2013@isb.gappspilot.info' IN (fieldValues.FLD_USER_IDS)

But it is not giving any result. is something wrong in it.?

Answer1:

You have to use FIND_IN_SET for more information see the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set" rel="nofollow">documentation</a>

This query should give you the correct result:

select fieldValues.FLD_USER_IDS from TBL_STD_FIELD_VALUE as fieldValues where FIND_IN_SET ('akshay_goel2013@isb.gappspilot.info',fieldValues.FLD_USER_IDS)

Recommend

  • MySQL JOIN by SELECT earliest DATETIME
  • How can I find the id of a gang in OpenACC?
  • Can to do one query from two queries?
  • Is there any better way to write this query
  • Scraping data from the tag names in python
  • 1:1 Alignment of C# Structs with Streamed Delphi Records Possible?
  • How do I scroll HTML textbox to the end?
  • Iteration over the dictionary and extracting values
  • how to get href link from onclick function in python
  • Making cut/replace methods with JTextArea
  • Foreign key constraint error when adding through migrating
  • Excluding some combinations from left join in MySQL
  • Space between buttons and window
  • PHP MYSQL event listener
  • Workflow - Database Design
  • Modify a Google App Engine entity id?
  • How can I see a list of all files that are different between two Hg repositories?
  • Receiver has no segue with identifier“***”
  • Is there any purpose for h2-h6 headings in HTML5?
  • Prolog Ambiguous Output
  • MVC - @Html.CheckBoxFor
  • Updating Dojo provide
  • Checking if an array in C is symmetric
  • How do I access an unhandled exception in an MVC Error view?
  • Ionic 2 storage is not cleaning up on uninstall - Only for signed APK
  • Email verification using google app script and google forms
  • Email format validation in mvc3 view
  • Is there any way to access browser form field suggestions from JavaScript?
  • Can I display google adwords (AdView) in javafx on android
  • Can I make an Android app that runs a web view in Chrome 39?
  • sending/ receiving email in Java
  • Convert array of 8 bytes to signed long in C++
  • Do I've to free mysql result after storing it?
  • How do I rollback to a specific git commit
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • Understanding cpu registers
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • Sorting a 2D array using the second column C++