Friday, 14 April 2017

How to do insert statement to input multiple ids in a column? SQL statement

There are two tables, first one is country_sports with columns country_id, country_name, sports_id and date. Second one is sports with columns sports_id, sports_name, sports_date.

When I post a form in web app by giving sports_name and choose the list of sports, then I want to create a insert statement that selects the sports_name and gets the list of sport's id and put it into the first table 'country_sports'.

Here, sports_id should have multiple ids.

For example,

insert into country_sports (country_id, country_name, sports_id, date) 
values ('', '', '', curdate()); 

For example, the data structure should be

('1', 'germany', '1, 2, 3, 4', 12-02-2017); 



via John Smith

No comments:

Post a Comment