Reputation: 1948
I have 3 tables: TimeTable
, Subject
, WeekDay
.
The TimeTable
table has the following fields: SubjectId
, WeekDayId
.
I want to insert values into the TimeTable
table, but the data comes in names, not id.s
, so I want to execute this statement:
Insert into TimeTable SubjectId , WeekDayId
Select WeekDay.WeekdayId , Subject.SubjectId from weekday , Subject
Where Subject.SubjectName=IPSubjectName And Weekday.WeekDayName=IPWeekDayName
Now I have 2 questions:
Is this statement available in sqlite (Am I writing it right)?
How can I dynamically take input at these values (IPSubjectName, IPWeekDayName).
i.e If I have var SubjectName, var WeekDayName, how will the statement be written then?
Upvotes: 1
Views: 287
Reputation: 349
I'm assuming you wrote a PHP function which calls this query, in which case, your variable names would become $SubjectName
and $WeekDayName
. Then, your code will become:
Where Subject.SubjectName=$SubjectName AND Weekday.WeekDayName=$WeekDayName
Upvotes: 2
Reputation: 233
Pass the values as parameters in the function where you are executing the query and replay the right hand side clause with ${paramname1}
and ${paramname2}
.
Upvotes: 0