473,625 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search rows back in table mysql

263 Contributor
Hi everyone.

My table mysql is:

Expand|Select|Wrap|Line Numbers
  1. ID    Dist     Date         Hour
  2. 15    LT     22/10/2009     08:56:05 
  3. 14    RM     22/10/2009     08:55:20  
  4. 13    RM     22/10/2009     08:55:19  
  5. 12    RM     22/10/2009     08:51:22    
  6. 11    LT     22/10/2009     08:47:19
  7.  
I try this query and working:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2. TIMEDIFF(b.hour, a.hour) AS strDiff 
  3. FROM doTbl_A a JOIN
  4. doTbl_A b ON 
  5. a.ID=b.id-1 OR
  6. a.ID=b.id-2 OR
  7. a.ID=b.id-3 OR
  8. A.ID=b.id-4
  9. WHERE a.DIST=b.DIST 
  10. AND a.DATE=b.DATE ORDER BY a.ID
But I do not know the exact location of the rows... can you help me?
Oct 22 '09 #1
2 2035
Atli
5,058 Recognized Expert Expert
Hey.

Could you explain that a little better?

What exactly are you expecting to happen?
What is actually happening?

P.S.
Be careful with your names. Both 'date' and 'hour' are reserved MySQL keywords, so it is not a good idea to use them as column names. Even tho it may not be a problem in certain situations, it may be in others.

If you do use them, it is best to enclose them in back-ticks (`). That way you can be sure they aren't causing problems.

Also, it is best to always write out database, table and column names is their proper case. In certain situations, 'A' is not the same as 'a'. Best to keep it consistent, and always use one or the other. (See line #8 in the query you posted)
Oct 22 '09 #2
viki1967
263 Contributor
Atli:

I need showing a time difference between rows.

If a.DIST=b.DIST and a.DATE=b.DATE and strDiff is < 1 hour I need show the rows.

This is my table:

Expand|Select|Wrap|Line Numbers
  1. ID    Dist     Date         Hour
  2. 15    LT     22/10/2009     08:56:05 
  3. 14    RM     22/10/2009     08:55:20  
  4. 13    RM     22/10/2009     08:55:19  
  5. 12    RM     22/10/2009     08:51:22    
  6. 11    LT     22/10/2009     08:47:19 
  7.  
The difference 08:56:05 (ID=15) and 08:47:19 (ID=11) is < 1 hour... only ID=11 is valid, ID=15 is not valid...

In the table mysql I do not know the exact location of the rows ...

You understand me?
Oct 22 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
11209
by: leegold2 | last post by:
Below is some code from a FULLTEXT search. My question is how do I get a count of the number of rows found by the search? $query="SELECT * FROM balloon_txt WHERE MATCH(access_no, recs_txt) AGAINST ('meteorology')"; $result = MySQL_query($query);
0
5764
by: Phil Powell | last post by:
The table already has a fulltext index and from there I can use the MySQL fulltext search query to get results as well as the relevancy score. The problem I have is that MySQL has a default setting whereby the minimum amount of characters is 4 for a search. Being that we're government and full of TLA (three-letter acronyms), that is not practical, and furthermore, the app I'm building must be fully portable, so having MySQL tweaked...
5
2279
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code of the two pages. What am I missing? This page calls the script datersearch.php ************ searchrdates.php ************
2
2716
by: Torfi Sackbatten | last post by:
Hi Everyone, I´m asked to "speed up" a keyword search based on MySQL. The material i´m given to work with is a quite large MySQL table with 1.5 mio rows, defined something like: CREATE TABLE datarecords ( id BIGINT(20) NOT NULL auto_increment, , keywords TEXT NOT NULL,
83
5909
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd expect a much faster performance. I submitted my search over two minutes ago. I just finished this email to the list. The results have still not come back. I only searched for: SECURITY INVOKER
1
6412
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
1
3430
by: B | last post by:
Hello All, This is my first time using this list, but hopefully I got the right one for the question I need to ask :). I have a table which has about 4 million records. When I do a search (as I will explain below) it takes about 1.35 secs to get me back what I am looking for. Since I am doing multiple types of these searches, the total time goes in minutes, therefore, I am trying to see if I can get any help in reducing this time...
4
1717
by: | last post by:
Hello... i have a table which contains a column named "ask" and a column named "per"... my think is that i want to search in "ask" and echo the data stored in "per" for this entry... How do i do this? Thanx in advance! JBK
13
2108
by: jfarthing | last post by:
Hi everyone! I am using the script below to search a db. If the is more than one match in the db, all goes well. But if there is only one match in the db, nothing gets displayed. Any suggestions will be greatly appreciated. Jim #! /usr/bin/perl -w use strict;
0
8192
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
8637
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...
0
8502
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
7188
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
5571
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
4090
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
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
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.