Solved

Mysql Query

Posted on 2000-04-13
2
231 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 68 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 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