PHP/MYSQL Joining Tables

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • In this video, I show you the simplest method for joining two or more tables together to build a successful query.

Комментарии • 20

  • @philliprapp4124
    @philliprapp4124 3 года назад +2

    Life saver bro, shouldn't have passed out during my prof's lecture

  • @aouxswantoro5432
    @aouxswantoro5432 2 года назад

    You are one of the best teachers in the world, knows clearly ho to utter the stuff. Thank you...!

  • @huumerin
    @huumerin 5 лет назад +3

    Your voice is nice and professional...this query is a great idea, please make more videos :)

  • @basi9343
    @basi9343 2 года назад +1

    thank you Sean!

  • @mercyovest
    @mercyovest 2 года назад +1

    Thank you very much John!

  • @DramaticOgre
    @DramaticOgre 6 лет назад +2

    Nice, your tutorials are very good.

  • @actually_yali
    @actually_yali 3 года назад

    Thank you for explaining it so clearly : )

  • @galer041
    @galer041 4 года назад

    Thank you, loud and clear.

  • @Pshickman
    @Pshickman 4 года назад

    Thanks man, you saved my life :)

  • @WliveTV
    @WliveTV 5 лет назад +2

    thank you, could you make more tutorials on php please.

  • @DavidAshby1
    @DavidAshby1 2 года назад

    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

    • @DavidAshby1
      @DavidAshby1 2 года назад

      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

  • @mnunez6153
    @mnunez6153 4 года назад

    i presume the output is dynamic. If need to save this new output (display) as a new table recorded in the database, how to?

    • @phpBasics
      @phpBasics  4 года назад

      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

    • @mnunez6153
      @mnunez6153 4 года назад

      @@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

    • @mnunez6153
      @mnunez6153 4 года назад

      i mean to say like this: $query= ""SELECT ...._serial = t1.ticket_serial"";

    • @mnunez6153
      @mnunez6153 4 года назад

      Then how to display the output of these code ...

    • @mnunez6153
      @mnunez6153 4 года назад

      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..

  • @rohitkc9780
    @rohitkc9780 4 года назад

    I need help in this a little bit could you please respond so I can ask you my question in detail.

    • @phpBasics
      @phpBasics  4 года назад

      Send me a message on Skype: CoolEditz