If wanting all fields returned from 1 table it would be SELECT * FROM table ...... I have the query woirking with the primary key from the main table connecting to the foreign key in the secondary table and on rowCount returns 76 entries however I want all the data to show from both tables. How would you go about that? In the select query, $sql = "SELECT courses.id AS course, outline.course_id AS lessons FROM courses, outline WHERE courses.id = outline.course_id ORDER BY course_id;"; So to retrieve all the data from both tables I will need to go through naming each col table.column? Thanks
I have eventually ended up with the following query $sql = "SELECT courses.id AS course_id, courses.author AS author, courses.subject AS subject, courses.coursedate AS coursedate, courses.numberofvids AS videos, courses.url AS url, courses.notes AS notes, outline.course_id AS lesson_id, outline.course_outline AS lesson_title, outline.additional_info AS notes2 FROM courses, outline WHERE courses.id = outline.course_id ORDER BY course_id;"; Is there a shorthand I can use for this? Thanks
Typically you wouldn't join two tables together to create a new table. However, if that's your goal, simply follow standard MySQL Create Table functions
@@phpBasics i see. So I have this sql statement, can you pls. help me figure out how to make the php query and how to write the query to put the output into display table..select t1.ticket_serial, t1.printed_copies, coalesce(t2.sold, 0) sold, t1.printed_copies - coalesce(t2.sold, 0) balance from table1 t1 left join ( select ticket_serial, count(*) sold from table2 group by ticket_serial ) t2 on t2.ticket_serial = t1.ticket_serial
the above code is basically combining 2 tables, to obtain the number of occurrence of data in every row of a particular column, of which its output is to be subtracted from the original quantity , thus we can calcuate the balance..
Life saver bro, shouldn't have passed out during my prof's lecture
You are one of the best teachers in the world, knows clearly ho to utter the stuff. Thank you...!
Your voice is nice and professional...this query is a great idea, please make more videos :)
thank you Sean!
Thank you very much John!
Nice, your tutorials are very good.
Thank you for explaining it so clearly : )
Thank you, loud and clear.
Thanks man, you saved my life :)
thank you, could you make more tutorials on php please.
If wanting all fields returned from 1 table it would be SELECT * FROM table ...... I have the query woirking with the primary key from the main table connecting to the foreign key in the secondary table and on rowCount returns 76 entries however I want all the data to show from both tables. How would you go about that?
In the select query,
$sql = "SELECT courses.id AS course, outline.course_id AS lessons FROM courses, outline WHERE courses.id = outline.course_id ORDER BY course_id;";
So to retrieve all the data from both tables I will need to go through naming each col table.column?
Thanks
I have eventually ended up with the following query
$sql = "SELECT courses.id AS course_id, courses.author AS author, courses.subject AS subject, courses.coursedate AS coursedate, courses.numberofvids AS videos, courses.url AS url, courses.notes AS notes, outline.course_id AS lesson_id, outline.course_outline AS lesson_title, outline.additional_info AS notes2 FROM courses, outline WHERE courses.id = outline.course_id ORDER BY course_id;";
Is there a shorthand I can use for this?
Thanks
i presume the output is dynamic. If need to save this new output (display) as a new table recorded in the database, how to?
Typically you wouldn't join two tables together to create a new table. However, if that's your goal, simply follow standard MySQL Create Table functions
@@phpBasics i see. So I have this sql statement, can you pls. help me figure out how to make the php query and how to write the query to put the output into display table..select
t1.ticket_serial,
t1.printed_copies,
coalesce(t2.sold, 0) sold,
t1.printed_copies - coalesce(t2.sold, 0) balance
from table1 t1
left join (
select ticket_serial, count(*) sold
from table2
group by ticket_serial
) t2 on t2.ticket_serial = t1.ticket_serial
i mean to say like this: $query= ""SELECT ...._serial = t1.ticket_serial"";
Then how to display the output of these code ...
the above code is basically combining 2 tables, to obtain the number of occurrence of data in every row of a particular column, of which its output is to be subtracted from the original quantity , thus we can calcuate the balance..
I need help in this a little bit could you please respond so I can ask you my question in detail.
Send me a message on Skype: CoolEditz