?
Solved

Mysql Query

Posted on 2000-04-13
2
Medium Priority
?
234 Views
Last Modified: 2006-11-17
Here is my mysql question :

I have 3 tables :

create table Categorie (
      IDCat bigint(21) NOT NULL auto_increment,
      Cat varchar(255) NOT NULL,
      PRIMARY KEY (IDCat)
)\p\g

create table Region (
      IDReg bigint(21) NOT NULL auto_increment,
      Reg varchar(255) NOT NULL,
      PRIMARY KEY (IDReg)
)\p\g

create table Agenda (
      IDAgen bigint(21) NOT NULL auto_increment,
      IDCat bigint(21) NOT NULL,
      IDReg bigint(21) NOT NULL,
      Descrip varchar(255) NOT NULL,
      PRIMARY KEY (IDAgen)
)\p\g

I have this query :
$result = mysql_query("SELECT Categorie.IDCat,Categorie.Cat FROM Categorie left join Agenda on Agenda.IDCat = Categorie.IDCat where Agenda.Descrip <> '' and Agenda.IDReg = '2'", $db);

This query returns several record that contains the same value, I would like them to be listed only one time.  How could I do that?

Thank you



0
Comment
Question by:cybernietic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
us111 earned 272 total points
ID: 2711154
Your table definition is not really useful :)

Just add the DISTINCT function in your mysql query.
$result = mysql_query("SELECT DISTINCT Categorie.IDCat,Categorie.Cat FROM Categorie left join Agenda on Agenda.IDCat =
                      Categorie.IDCat where Agenda.Descrip <> '' and Agenda.IDReg = '2'", $db);

DISTINCTROW is you have several same records.

0
 
LVL 1

Author Comment

by:cybernietic
ID: 2714982
Excellent! Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question