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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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