Storing table in a sql table

I want store table.




local sometable = {"hey","hey2","hey3"}

query = "CREATE TABLE data_test ( id varchar(255), table sometable)"

sql.Query(query)



Or should I use util.TableToJSON make table to string then store it like that?

Tables in SQL databases and Lua tables are not the same.

And yes, you can convert the lua table to JSON string and then read it.

This is very bad practice, you should always avoid storing a JSON string in a database table unless for some specific situations which likely don’t apply. Let say you later on want to write a query to sort by a field in your table- no possible. Search by a key? Not possible. You should create columns for each key in your table then insert each thing separate.