Search code examples
mysqlphpmyadminrecords

Displaying certain records from MySQL statement


I want to display only certain records from my products table

Structure of products table: products structure

Structure of suppliers table: suppliers table

I want to display all product IDs, product descriptions, product prices, and the supplier company name and contact phone number for all products and list them in descending order of price. How do I do this using MySQL?


Solution

  • [Per your edited post] you need to JOIN with both table and Add a ORDER BY Price DESC in your SELECT statement; like

    select p.`prod_id`, p.`prod_name`, 
    p.`price`, s.`company_name`,
    s.`phone`
    from products p join suppliers s on p.supp_id = s.supp_id
    order by p.`price` desc;