I am currently fetching data using the statement
$queryfetchBookings="SELECT `id`,`sessionHeld`,`fk_student_id`,`channelName`,`video_duration`,`audio_duration`,`category`,`dateBooked`,`timeSlot`,`duration`,`category`,`studentName`,`overallRating`,`chat_duration` FROM `one_to_one_bookings` WHERE fk_co_id=".$co_id;
I now want to add an
ORDER BY `id` ASC
to the end but whatever variation I have tried results in failure.(Does not fetch data). Need advice on how to proceed.
2
Answers
I am not sure about how the server you are using works, but in oracle it would not work because after the WHERE clause you are adding a ";". At least in oracle this would mean that the query is over, so I am guessing this is why it is not considering your last sentence.
I hope I can help 🙂
First of all, you should use prepared statements to avoid SQL injection, and not concatenating strings to your query.
You are doing wrong your concatenation in PHP, you need to add a
.
and some quotes:The problem was at the end of the query: