1

I have a list of events in MySQL where there's event titles, event time, date etc. In each event there are invitees (people who got invited to the event).

So basically my table events table looks like this:

enter image description here

By looking at the table you'll notice that my event_invitees is an array, I managed to save an array using a tutorial here. So from this tutorial I am able to get the array out out the table.

What I want to so is SELECT a column form the table WHERE myString is in the event_invitees array

So using the image above as an example. I have a string "tnylee" I want to be able to select every row that contains the event_invitees called tnylee.

How can I do this? Is this possible? Please comment if the question isn't clear enough

Any help will be greatly appreciated. Thank you.

2
  • you want to select based on the items inside the serialized string? oh no Commented Sep 3, 2014 at 8:39
  • @Ghost YES. How can I do this? Commented Sep 3, 2014 at 8:42

2 Answers 2

1

You can use like keyword for filter the data

SELECT * FROM table_name WHERE event_invitees LIKE '%tnylee%'

then you will receive results the column value as "tnylee" pattern.

You can check if the selected row contains exact value when you extract data(Using programme).

Sign up to request clarification or add additional context in comments.

1 Comment

You can check the retrived data exact match with the result by programme
0

Instead of storing event_invitees in one serialized column better solution is to keep them in dependend table

this table will containt:

CREATE TABLE `CREATE TABLE `table_code` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_person` integer NOT NULL,
  `id_event` integer  NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

Anyway You can use 'LIKE' operator: SELECT * FROM events WHERE event_invitees LIKE '%YourSearch%'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.