473,698 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stop repeat entries

Can you stop pulling out exactly the same data from a database, for
example, if you had 2 entries which had the name Chris, it would only
print Chris once?
Jul 16 '05 #1
3 2345
Damien wrote:
Can you stop pulling out exactly the same data from a database, for
example, if you had 2 entries which had the name Chris, it would only
print Chris once?


You could use SQL's DISTINCT keyword, but that would only work if every
row in your resultset would be a match.

for instance, given the table

fname | lname
------+------
Chris | Smith
Chris | Jones

SELECT DISTINCT(fname) FROM tblName WHERE fname='Chris' would work, where

SELECT DISTINCT(*) FROM tblName WHERE fname='Chris' wouldn't.

You might be able to do it with some nasty JOINs but those are evil and
kill your performance.

Jul 16 '05 #2
Actualy, if you are using SQL, I would use a LIMIT command as follows

SELECT fname FROM table WHERE fname = Chris LIMIT 1;

--
Your GP or your HP!
Warren Butt

"Joshua Ghiloni" <jd***@SPAM.ME. AND.DIE.cwru.ed u> wrote in message
news:bg******** **@eeyore.INS.c wru.edu...
Damien wrote:
Can you stop pulling out exactly the same data from a database, for
example, if you had 2 entries which had the name Chris, it would only
print Chris once?


You could use SQL's DISTINCT keyword, but that would only work if every
row in your resultset would be a match.

for instance, given the table

fname | lname
------+------
Chris | Smith
Chris | Jones

SELECT DISTINCT(fname) FROM tblName WHERE fname='Chris' would work, where

SELECT DISTINCT(*) FROM tblName WHERE fname='Chris' wouldn't.

You might be able to do it with some nasty JOINs but those are evil and
kill your performance.

Jul 16 '05 #3
Joshua Ghiloni wrote:
Damien wrote:
Can you stop pulling out exactly the same data from a database, for
example, if you had 2 entries which had the name Chris, it would only
print Chris once?

You could use SQL's DISTINCT keyword, but that would only work if every
row in your resultset would be a match.

for instance, given the table

fname | lname
------+------
Chris | Smith
Chris | Jones

SELECT DISTINCT(fname) FROM tblName WHERE fname='Chris' would work, where

SELECT DISTINCT(*) FROM tblName WHERE fname='Chris' wouldn't.

You might be able to do it with some nasty JOINs but those are evil and
kill your performance.


Yes forget I said all this. I've been at work too long today, and I'm
tired :)

Jul 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2409
by: Harald Armin Massa | last post by:
I need to do some synchronisations like in a cron.job import time from threading import Thread class updater(Thread): def run(self): while True: do_updates() time.sleep(600)
3
2689
by: Bryan Capps | last post by:
I have a text box control on a form, the value of which is calculated (concatenated) from entries on a subform. Accordingly, I've set the control's locked property to true and the tab stop property to false. The latter setting makes the control completely disappear. FYI, the form is dialog border style. When set to sizable border style, the control only appears when the form is re-sized much larger. I have a similar form with a...
4
1319
by: tsiGeorge | last post by:
When the web page takes a while to process users get impatient and click the button again. I need to throw these extra clicks away or disable the button after the first click. -- tsiGeorge
7
5453
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words <http://www.sai.msu.su/%7Emegera/oddmuse/index.cgi/Tsearch_V2_compound_words> I used the german myspell dictionary from http://lingucomponent.openoffice.org/spell_dic.html and converted it with my2ispell
6
1423
by: Simon Gare | last post by:
Hi I have a booking page that the user enters 2 addresses date and time etc what I need is the option for the user to select multiple date entries for the same journey or maybe multiple days ie they want to travel the same journey every Monday or every weekday etc. Thanks in advance Simon Gare
2
2271
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg, President eSolTec, Inc. a 501(C)(3) organization MS Authorized MAR looking for used laptops for developmentally disabled.
5
2199
by: =?Utf-8?B?Sm9uYXRoYW4gU21pdGg=?= | last post by:
I have written a service, but it won't stop, Eventvwr reports the following: "Failed to stop service" The code is as follows: ============================================ Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work.
6
2921
by: Wernerh | last post by:
Hi I want to stop a code firing if a certain condition is not met. I only want to allow numeric entries in the textbox to allow the code to run. I tried with the first line of code to stop it, but obviously am failing in my attempt. If 26 = AlphaNumeric Then Stop Dim ba26 As String Dim fileName As String fileName = App.Path & "\" & "\data\ba26.txt" ba26 = FreeFile Open fileName For Output As #ba26
33
11617
by: Sunny | last post by:
Hi, Sometime, when your script is too big, IE Gives you a warning "Stop Running This Script" A script on this page is causing Internet Explorer to run slowly. Does anyone knows, How to correct that? Thanks.
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.