Jump to content

[SOLVED] Selecting problems


ccrevcypsys

Recommended Posts

I have a website that has users and artists on it. I am building the community page ( the page that displays everyone in the db) well i figured out the view all artists and all people but i need help figuring out how to just view the customers without the artists on the page.

 

My db is set up like this

 

--|customers|--          --|artists|--

  screenname      +---customer_id

  email                      points

  password

  customer_id ---+

 

and my code for the query is this so far

$query = "SELECT * FROM ".$glob['dbprefix']."StreamRush_customer LEFT JOIN ".$glob['dbprefix']."artist ON ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."artist.customer_id WHERE private = 0 ORDER BY noOrders";

Link to comment
https://forums.phpfreaks.com/topic/75845-solved-selecting-problems/
Share on other sites

select ".$glob['dbprefix']."StreamRush_customer.* FROM ".$glob['dbprefix']."StreamRush_customer LEFT JOIN ".$glob['dbprefix']."artist ON ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."artist.customer_id WHERE private = 0 ORDER BY noOrders";

or select only one table
select * from ".$glob['dbprefix']."StreamRush_customer where etc.....

IF you mean those customers without a matching artist record

 

(using aliases to make the query legible, and line breaks so you don't need a 45 inch plasma screen to view)

 

<?php
<?php 
$query = "SELECT * 
            FROM ".$glob['dbprefix']."StreamRush_customer c
            LEFT JOIN ".$glob['dbprefix']."artist a
            ON c.customer_id = a.customer_id 
            WHERE private = 0
                AND a.customer_id IS NULL 
            ORDER BY noOrders";
?>

 

BTW - where did "private" and "noOrders" appear from?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.