0

I'm having an issue with figuring out my INSERT query.

What I want to do is the following:

I want to insert the availability of a user based on his giving information.

The user got a simple dashboard with:

Day ( ) Yes / ( ) No - Start time: XXXX End time: XXXX

For the day i use a radio button from monday till sunday with yes having its value="" being the name of the day and the name="" attribute named day.

No is empty which is set to default NULL,, and start end time use an input field with type="time"

My Table is setup as followed:

Table name: Availability

available_id (AI), 
available_worker_id  
available_day,(text) 
available_start(text), 
available_end(text)

Now here come's the part I cant figure out,

What if I select Monday Friday and Sunday only ? How would I create a query where the results would be as followed:

[1] [Monday] [1] [09:30] [12:50]
[2] [Friday] [1] [10:40] [17:30]
[3] [Sunday] [1] [07:00] [21:00]

Would I require to create the insert as followed:

INSERT INTO `availability` (`available _day`,` available_start`, `available _end`) VALUES (?), (?,?) 

Because with this query I'll be ending up that the cols available_start, available_end getting there own values from my post and that the available_day get its own value's. Atleast that is what I understand so far with my knowledge.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Tim
  • 11
  • 3
  • What **exactly** have you tried so far? What's not working when using the three data sets for the query? `VALUES (?), (?,?) ` looks wrong to me, as you should not have to sets of parameterized rows – Nico Haase Nov 08 '22 at 10:59
  • You can insert two rows in one INSERT no problem, but you need to understand that the same fields have to be input into each row, the fields cannot be spread across rows like this.. – ADyson Nov 08 '22 at 11:05
  • So a query to insert 3 rows into the table would be like this: INSERT INTO `availability` (`available _day`,` available_start`, `available _end`) VALUES (?, ?, ?), (?, ?, ?), (?, ?, ?) – ADyson Nov 08 '22 at 11:07

0 Answers0