Jump to content

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']."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

Can't work out your DB is this one table of both or 2 seperate tables?

could you itemise them downward for each?

 

Desmond.

 

its 2 different tables

customer is its own table

and

artist is its own table

 

and the customer table has everyone registered on the site but the artist table says who is the artists.

Link to comment
Share on other sites

I have also tried this

$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 ".$glob['dbprefix']."StreamRush_customer.customer_id!=".$glob['dbprefix']."artist.customer_id AND private = 0 ORDER BY noOrders";

and it causes the table not to generate

Link to comment
Share on other sites

Try something like this :-o

 

$artists = mysql_query("SELECT customer_id FROM artists");
$artist = mysql_fetch_array($artists);
//$artists is now an array of ALL customer ids that are artists :-o

mysql_clear_result($artists);//clear off the memory so you can perform another query efficiently

$customers = mysql_query("SELECT screenname,email,customer_id FROM customers");

while($row = mysql_fetch_array($customers)){//loop through all your registered users
if(!in_array($row['customer_id'],$artists)){//they are not an artist
//do some html to display customer data
}
}
mysql_clear_result($customers);//clear off the memory so you have efficiency :-D

 

Let me know if this code makes sense or not. I'd rather use codes like this than mess with LEFT JOIN, RIGHT JOIN, etc... where I can.

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.