zwork zwork - 5 months ago 10
SQL Question

Selecting certain columns from a single row that contain @

I am attempting to extract a single row from a MySQL database table, but with certain parameters specified. The username of the row has to match what was used to login, and the variable

$groupname
must match as well. I only want to pull out data from the columns whose data contains the @ symbol (so that I know it's an email). What is the best way to do this?

EDIT: The table has the following rows:
id
,
timestamp
,
username
,
groupname
, and group emails labelled
ge1
-
ge10
. I want to pull out only the
ge
columns from a single row that have content.

Answer

Use a SQL query to check if the username and the groupname match, and add another condition for finding some character in a string (in this example the "@") after that you should parse the string in which the above constraints are met , this can be done using for loops(which is basically iterating over the string) or using recursive queries in sql , see this link

Comments