473,729 Members | 2,355 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 2346
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
2410
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
2692
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
1324
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
5461
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
1426
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
2275
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
2202
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
2927
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
11627
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
8761
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
9426
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
9281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6022
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
4525
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...
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.