Re: SQL Newbie Database search question

From: Date: Wed, 31 Jan 2001 15:14:02 +0000
Subject: Re: SQL Newbie Database search question
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6285@lists.php.net to get a copy of this message
add DISTINCT to your query .... select distinct specific_p, qty from database where specific_p = 68030 and qty > 0 For you second requirement, get them all, and just use the first one ... can't remember exact syntax but something like select specific_p from database where specific_p like %68030% limit 1 or maybe it's TOP 1. Can't remember. Check your Sql Server docs. Miles At 08:28 AM 1/31/01 -0600, Robert wrote:
I have a database with several fields... I only want certain fields to show in my results Some of the searched fields have the same value example: searched field is specific_p
specific_p       comment   qty
68030              9845         0
68030              9844         100
68030              9843         12
68030rc50        9843         50
I want to show the 68030, but not the comment. I also don't want to show three seperate 68030s and pick one that is not 0 qty if there is one. Is there an MSSQL command to only get one of them? There may be other parts that are close too I want to search for %68030% to get all of them but show only one of them. I could probably write a filter, but WHY if it is built into SQL?


« previous php.db (#6285) next »