0

I want to select the record of a single customer, let's say a customer whose id is 2 from the table named giftcards. In giftcards the id of customers is store in JSON format (column = customerid). How can I do this? I'm working with PHP.

enter image description here

Gifcards table structure is shown here

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 5
    Don't do that. You should have a table that maps `gcid` to `customerid`s. – Niet the Dark Absol Oct 18 '21 at 17:19
  • you have a json so you need to use them or normalize the tables – nbk Oct 18 '21 at 17:20
  • It's possible with new MySql version, but not efficient. Also there should be indexes on `customerid` to link faster to customers. In small database you will see no big difference, but if it grows - maintenance and speed will be your pain in the _back_ – Justinas Oct 18 '21 at 17:22
  • You might want to read https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad for saving complex data into one column – Progman Oct 18 '21 at 17:26

0 Answers0