473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2333
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.edu> wrote in message
news:bg**********@eeyore.INS.cwru.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
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
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...
4
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
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...
6
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...
2
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,...
5
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...
6
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...
33
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.