Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Get The Latest Changed Records


I hava a table with the following information

CREATE TABLE TEMP1 (REFID INT, REVISION INT, FIELDNAM VARCHAR(10), VALUE VARCHAR(10));
INSERT INTO TEMP1 VALUES(1001, 0, A, A2);
INSERT INTO TEMP1 VALUES(1001, 0, C, C2);
INSERT INTO TEMP1 VALUES(1001, 0, E, E2);
INSERT INTO TEMP1 VALUES(1002, 0, A, A3);
INSERT INTO TEMP1 VALUES(1002, 0, B, B2);
INSERT INTO TEMP1 VALUES(1002, 0, E, E3);
INSERT INTO TEMP1 VALUES(1001, 1, A, A4);
INSERT INTO TEMP1 VALUES(1001, 1, E, E4);

Here based on latest revision and refid I should get the fieldnam and value.
Expected output:
REFID FIELDNAM VALUE REVISION
1001 A A4 1
1001 E E4 1
1002 B B2 0
1001 C C2 0




View Complete Forum Thread with Replies

Related Forum Messages:
Revert To Latest Records
I have about 6 months of experience with PHP and MySQL, but I'm new to the forums. I need a kind of rigged up SELECT ... WHERE statement.

SELECT * FROM splits WHERE month='6' AND year='2007'

I need it to select the latest records if no records exist for the desired month and year. I don't want to do a separate SELECT and just use mysql_numrows.

View Replies !
How To Get The Two Latest Records Per Unique Id?
How to get the TWO latest inserttime for each uid. If I just want to have the latest I do:

SELECT uid, MAX(inserttime) AS latestinsert FROM sometable GROUP BY uid

That results in the latest record per uid. But how to get the TWO latest inserttime per uid?

View Replies !
Latest 20 Records With Highest Price First
Im trying to pull 20 records out of the db where the query picks the latest 20 records and picks the highest priced items marked as "Sold" and it will drop off the lowest priced item when a new record is marked as "Sold".

View Replies !
Select Records For Latest Date
Multiple records with different dates, how i can only select the latest date?

View Replies !
I Changed Root Password But I Can Not Login With Changed Password
I changed the password of root with
update user set password=password('newpassword')

Then I exited. But when I want to login again , it cannot authenticate the root
I should tell you that a hacker had changed my root password before. Because it was not encrypted before.

View Replies !
Changed Characters
While using mysqldump to backup the databases on my server i noticed that all the the portuguese accented characters from my databases get screwed up and changed to wierd characters.
What's up?

View Replies !
Changed User Privileges And Now I Can't Log In
I read several web sites and O'Reilly's book on MySQL about securing the system tables.

I removed several users and, as advised inthe book and web sites, changed the user "root" to another name with another password.

I removed the site name as a host but kept the IP address.

Now when I use phpMySdmin to get back in, it let's me past the login popup BUT it gives me the message:

Error
MySQL said: Access denied for user: 'root@localhost' (Using password: YES)

The data in the database is not important but the database structure/definition is. I'd like to find a way to back up or dump that. Then I can reload MySQL and start over.

View Replies !
User Information Changed
The other day someone changed every user's password on my site. Then they changed every user's email address to theirs - I assume the reason was that when the user used the password reset function, they would never see the information.

I'm trying to research what/where the vulnerability is in the script that I'm suing, but I don't really know where to start - not being a hacker, I don't even know the terms to search for here or on google.

Is this what is meant by mysql injection?

View Replies !
Float(m,n) Changed Between Mysql 4.0 And 5.0?
I have a float(11,10) field (default NULL) in one of my MyISAM tables. With MySQL 4.0.16, I can call an Update/Insert query with a value of , say 33.166668 to this field, and it updates correctly. When I retrieve that value again with a select statement, I get something like 33.1666668392 (10 digits after decimal). Which is correct. (The sql_mode server variable is set to 0)

With the same field in MySQL 5.0, my experience is different. With the server sql_mode set to one of the strict values( SQL_TRANS_STRICT), i get an error about out of range value for the float field. when I change the sql_mode to not have the SQL_TRANS_STRICT, I get the same error as a warning, 1264 "Out of range...". When I retrieve this value, it is set to 10.0000000000, which is wrong. But , when I change the field description to float(11,5) and do an update, the value is updated right, but I get an intermittent "No rows updated" error.

Could anybody please explain if the float definitions changed between versions? Does float(m,n) now mean that I can have only (m-n) digits before decimal point?

View Replies !
Rows Changed In Update SQL
Is there a way to find out how many rows got updated when i execute a update stmt.

I would like to get the updated rows count in SQL.

Let me know and Thanks in advance.

update stmt where clause;

now how can i get the count of rows that got updated.

View Replies !
How To Find Out Which Table Is Changed?
I dont have source code of my web application I installed. Its using mysql 5. when I create a new user account, I know "users" tables is changed, but there's also a couple other tables are modified.

Is there a way I can find out which table is changed?

View Replies !
History Of Changed Percents
I have a table with data like that:

percent date
50% 2007-05-01
30% 2007-05-02
30% 2007-05-03
50% 2007-05-04
50% 2007-05-05
20% 2007-05-06
20% 2007-05-07
50% 2007-05-08
70% 2007-05-09
70% 2007-05-10

The query has to return this rows:

50% 2007-05-01
30% 2007-05-02
50% 2007-05-04
20% 2007-05-06
50% 2007-05-08
70% 2007-05-09

View Replies !
Changed Datadir Now Mysql Won't Run
I changed the datadir using mysql administrator (so I could "see it") (I'm using version 5.0.x under OS X 10.4.5 and now mysql won't run and I don't know how to reset the datadir. I've reinstalled mysql and when I try to run it this is what I get:

iBook-G4:/usr/local/mysql michael$ sudo ./bin/mysqld_safe &
[16] 12878
iBook-G4:/usr/local/mysql michael$ Starting mysqld daemon with databases from /Users/michael/Sites
STOPPING server from pid file /Users/michael/Sites/iBook-G4.pid
060329 12:38:24 mysqld ended

View Replies !
All Swedish Characters Is Changed
I'm doing Kevin Yanks tutorial about how to manage users with session (with some small modifications).

But when the data is inserted into the table all Swedish characters is changed to some strange "¥" and "¶". Why is it so and how to fix it?

According to PHPAdmin the collation is either UTF-8 (db) or Latin1_swedish (table)?

View Replies !
Changed Root Password, Now I Can't Do Anything
I am following the MySQL by Michael Kofler and looking at securing root access as currently it has no password.

I've logged into the MySQL consol and changed password using :

mysqladmin -u root -h localhost password XXX

However, i now can't do anything in in mysql terminal it comes back "access denied for user 'root'@'localhost' (using password :NO)

View Replies !
Date And Time Stamp A Changed Row
I am about to declare a table with 20 columns.

How do I create 4 more columns:
1. current Time
2. current Day of the month
3. current Month
4. current Year

Such that:

a. These 4 columns are not editable by the user.

b. Whenever a row is updated/inserted/replace/etc. then
these 4 columns in that row are automatically updated
by the system accordingly.

View Replies !
Datetime Field Changed After ALTER
To archive when a row is added, I have a column called date_added which uses the data type DATETIME.

I recently added a new column to my table "ALTER TABLE mytable ADD COLUMN mycolumn INT", and my stored dates have all been changed. In hindsight, was this to be expected?

I am using PHP to both push data into MySQL and pull data from MySQL. To prevent such future blunders, is it good practice to store dates as CHAR data type, and actively store the date using PHP?

View Replies !
Phone Numbers Changed On Import
I have imported a cvs data file every way I can think of and I always get this weird problem. About 75% of my 4,000 files end up with the phone number 2147483647. I searched the cvs file and this number does not exist there.
Is there an explaination for this?

View Replies !
Bug :: Floating Point Value 1.0 Changed To 1 When Inserting
when insert the floating point "1.0" in the tables, it is converted as "1" , is there anyway to store the exact floating point values?

my intention is to insert the values like "1.0" or "1.10" or "1.110" without any restriction.

description of the table is ...

View Replies !
Replication :: Master Log File Position Changed
I have a simple master/slave replication environment that is working smoothly with one exception. If I restart the master server the Master Log File is incremented by one (e.g. the original master log is named data-bin.000001 and the new master log is named data-bin.000002) the slave server never notices that the Master Log File and the Master Log Position have changed. Instead, the slave sits there waiting for new entries in the old Master Log File. I can tell this by executing a SHOW SLAVE STATUS on the slave server.

I am not sure about this because I can't find any documentation on the proper behavior of mysql during this scenario, however, I am under the impression that slave server should be able to figure this out and continue replicating, without requiring me to execute an "CHANGE MASTER..." command on the slave server every time the master is restarted. Of course, I assume this same problem will occur when the Master Log File grows to its maximum size and a new Master Log File is
created.

If anybody who has experience with mysql replication could just confirm that the behavior I am seeing is not correct, that would be great. Or if anybody has any suggestions as to what, if anything, is wrong with my setup. Code:

View Replies !
Row Cannot Be Located For Updating. Some Values Might Have Changed Since It Was Last Updated
I've recently migrated from access to mysql with vb6). Unfortunately, i get the following error whenever the .update is executed on the recordset.

"Row Cannot be located for updating. Some values might have changed since it was last updated"

The select statement is:
Select * from tablename, connection,3,3 (have also modified the 3,3, to be adOpenDynamic, adLockOptimistic)

I have tried checking the flag To Return Matching Rows, I've added the option = 2 in the connection string, i have a primary key field in the table, and I've also tried re-assigning it to itself.

View Replies !
Identify Columns Changed By Update Statement
It says in the documentation that "If you set a column to the value it currently has, MySQL notices this and does not update it." is there anyway to identify what column values have changed? i.e. what columns have been updated?

View Replies !
HostName Changed - Now MySql Server Wont Run
I've changed the hostname of my sever at long last, now what had been a very stable Mysql server won't run, can anyone point me in the right direction?

View Replies !
String Error - Quotes Changed To Question Marks
I recently converted an asp/access site to an asp/mysql site. Now all my strings are displaying funky. For example if I have the text - Why don't we say "Yipee" - it displays on my site as - Why don?t we say ?Yipee?. The same change is being made when I use a sentence with "..." in it. I like ... baseball is changed to - I like?baseball.

Any thoughts as to why this is happening? Sometimes it is actually being changed somehow in the database, and sometimes it is correct in the database, but then changed when it displays on the web.

View Replies !
Mysql Appears To Have Changed The 'password' Function Hashing
I've been using Mysql for about 6 months but in fairly basic fashion. For a cms I have built, I have a users table, with userName and password fields. An admin can create new users, and the password is hashed using the PASSWORD() function.
SQL: "INSERT INTO users VALUES ('', '$userName', PASSWORD('$userPwd'))

Straight out of the book basically. Now the problem is that all this has been functioning fine on a couple of sites on external servers, plus a couple of local machines.

Until today, on my main dev machine - yesterday a user could log in, today they couldn't. As far as I can tell, nothing has changed. But when I look at the hashes in the database table, they are 41 chrs, and when I add a new user, the hash is 16 characters.

I know that at some stage the hash length was increased between mysql versions, but I have not updated the install (I run XAMPP for Windows 1.4.14, which appears to install php 5.0.4 and mysql 4.1.12)

Is there any other reason that the hash length could change to 16? I'd like to know why this happened so that I'm prepared if it happens on the server (where it is not so easy to hack in and add new users that can log in again)

View Replies !
Latest Changes To A Row
Is there an easy way to get the time a row was modified last? I need it for a community-system where I want to get the time(-stamp) a user made the last changes to his profile without always update some `last_modified`-column every time he changes something.

View Replies !
Latest Enteries
I have a database made by a programmer on my site which has enteries for different diecast models in it. It is backended via a mySQL database, and uses php for the pages. It has a basic search function in it, however I am wondering if the following is possible.Is there a way that I could have one page that has the newest... say 20 enteries in it? How would I do this?

View Replies !
Latest Date
I'm new to mysql and i was programming some stuff in my website and i find that whenever i delete a row of data .. the next data that i insert will not be at the back of the table .. it will be inserted in the slot of the data that i already deleted it ..

how can i make the newest inserted data be at the back of the table?

View Replies !
Latest MySql5.0
i installed Mysql5.0.12 and 5.0.20, neither of which allowed the addition of a new user. Said no can save...user may have been deleted system is windows2003 server X86

View Replies !
Latest-date Query
I am trying to get all records that share the most recent "RatesUpdated" datetime value from 1 table. I am doing the below query and I keep getting the following syntax error: "#1111 - Invalid use of group function"
SELECT t1.Product, max(t2.RatesUpdated) FROM `lqdp_mortgage_rates` t1, `lqdp_mortgage_rates` t2
WHERE t1.RatesUpdated = max(t2.RatesUpdated)
group by max(t2.RatesUpdated)

View Replies !
Latest Date Inserted
i have a table 'NEWS' contains a date field that takes CURDATE() when any row inserted in it.and from another php page, i want to get 1 row with the latest date in this table, i.e. the last news row inserted.what should be the SQL query?

View Replies !
SELECT Latest Updates
I have these two tables:

"cats"

catid INT
catname VARCHAR

"messages"

messageid INT
messageparentid INT
catid INT
messageposted DATETIME
messageauthor VARCHAR
messagetext TEXT

What i need is to get all cats and include the column "messageauthor" from table "messages", but only the latest "messageauthor". That being the the post with the higest "messageid" and the same "catid" as parent table "catid".

SELECT * FROM cats ...

View Replies !
Latest Date Using 3 Tables
I am trying to join 3 tables with one table returning the latest date. Below is what I've tried. I need to display the current Rank from the record that latest date is from. What I'm getting is the latest date and the first rank (these are not the same record by the way).

What am I doing wrong? Can anyone help me? BTW, I'm using MySQL 5.0

SELECT Personnel.ID, Personnel.LastName, Personnel.FirstName, Ranks.Rank, Ranks.rankID, Promotions.DateOfRank
FROM Ranks
RIGHT JOIN (Personnel
LEFT JOIN (SELECT Promotions.MemberID, Promotions.RankID, MAX(DateOfRank) AS DateOfRank
FROM Promotions
GROUP BY MemberID) Promotions
ON Personnel.ID = Promotions.MemberID)
ON Ranks.rankID = Promotions.RankID
order by LastName, FirstName.

View Replies !
How To Retrieve Latest Date
I have a table that looks something like this:

table prop1 {
id;
addr;
zip;
name;
} (it's much larger than this)

And another table that looks like

table prop2 {
id;
price;
date;
}

The first table will have one entry per address. The second can have any number of entries with varying prices and dates. I need to retrieve the highest price with the latest date from prop2 for each entry in prop1.

I have tried this code:
select (p.id, p.addr, pp.id, pp.price, pp.date, MAX(pp.price) from prop1 p, prop2 pp where p.id = pp.id group by p.id order by p.addr);

This sort of does what I want. But it lists all of the results. So if one address has ten entries, all ten entries are returned. If I add a LIMIT 1, that works for the first address but no others are returned.

Is there a way to return just one entry for each address and have that entry be the one with the highest price and most recent date (or even just the highest price if need be)?

View Replies !
Getting The Latest Data From A Table
I have a table that has a date colum in it (colum is 'cheatdate'). So, I was woundering how I would use a MySQL query to get the latest 10 entrys (10 more recent dates). Can someone explain how I would do that?

View Replies !
Latest In Mysql Query?
I want to run a query, to export the 10 most recent rows. There are a few possible ways i can think of to do this. I have an id column that is autoincrement, so i think i could order them in desc, then limit to 10...would it work?

Or i also have a date column, so i guess with a little more work i could list by date. Any idea how to do this?

View Replies !
MySQL 5 Is Latest Version
The lastest full production release of MySQL is version 5.

Some hosts do not support version 5 yet but most should be supporting version 4.1.

If your version is older than 4.1 please note that in any new threads you start. This is because older versions do not support things like GROUP_CONCAT and subqueries among other things.

If you happen to still be on MySQL 3.x then you won't even have the ability to use UNION.

If you note that you are using an older version, then when someone is composing a solution to help you, they will give you a version that you can use on your particular release of MySQL.

Subqueries can be re-written as joins and in place of a UNION you may create a temporary table and then query results from it for instance.

View Replies !
Join/Group By On Latest Row
I have a database with 2 tables, the first one is for items, and the second is a status.
I want 1 query that just returns the item with the latest status, without using a subquery (older mysql version ). Is this possible?

Example tables:


CREATE TABLE `item` (
`id` int(11) NOT NULL auto_increment,
`description` varchar(20) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;

INSERT INTO `item` VALUES (1, 'First');
INSERT INTO `item` VALUES (2, 'Second');

CREATE TABLE `status` (
`id` int(11) NOT NULL auto_increment,
`value` varchar(50) NOT NULL default '',
`item` int(11) NOT NULL default Ɔ',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;

INSERT INTO `status` VALUES (1, 'First - First', 1);
INSERT INTO `status` VALUES (2, 'First - Second', 1);
INSERT INTO `status` VALUES (3, 'Second - ZFirst', 2);
INSERT INTO `status` VALUES (4, 'Second - Second', 2);


SELECT description, MAX(value)
FROM item AS i
INNER JOIN status AS s ON s.item = i.id
GROUP BY description

==>

-------------------------------
|[description] | [MAX(value)] |
===============================
|First First | Second |
-------------------------------
|Second Second | ZFirst |
-------------------------------
Gives the max value, but string based. I would like to get the value that goes with the MAX(id) of the status

View Replies !
Getting Topics By Latest Comments
tables are as follow:

comments:
-topic_id
-time
-text

topics
-id
-title
-text

Now if I try:

SQL Code:
SELECT t.id, t.title, c.topic_id FROM comments c INNER JOIN topics t ON
 t.id=c.topic_id ORDER BY c.time DESC LIMIT 3

View Replies !
Get 5 Latest In Random Order
I'm trying to get the 5 latest records and order them randomly, but this doesnt seem to work - any ideas...

select article_head
FROM news
WHERE article_status = '1'
ORDER BY article_date DESC, RAND()
LIMIT 5

View Replies !
Select Latest Record Per Group
im trying to write a query that gets the last record inputed for each group. There are 4 groups...

Electrical
Mechanical
Indirects
Staff

This is my current query ....

View Replies !
Sorting Column1 By Latest Entry
SELECT time,referer FROM site_stats GROUP BY referer ORDER BY time DESC

this worked, however referer that comes first is at the bottom of the table although the referer entry is latest.. only refererer that havent been listed yet are on the top .. so what happens is now that it shows referer according to its latest existance ...
how can i do it so that the latest referer is ontop according to the latest time. .. which mean which ever referer that comes in by latest its group will be on top of the list ..

View Replies !
Find Out The Date Of The Latest Sunday
Today is 26 December 2006, I want to find out what is the date of the latest sunday that passed by...the date of latest sunday given any day..

what function is used? how to find out?

View Replies !
Want To Get Latest Record From Multiple Tables
Want to get latest record from multiple tables, I currently have:

SELECT PRICE FROM STEEL_2008, COPPER_2008, ALUM_2008, CARBON_2008 ORDER BY TIMESTAMP desc limit 1

Which isn't returning any records. Also is this the most efficient way to get the latest record?

View Replies !
Selecting The Latest Date Entry
Basically I have a table containing these 4 fields
selection_ID - user_ID - visit_date (date field) - period_of_day

All I want to do is select one row - the one with the most recent visit_date for a particular user_ID.

I am using mySql 4.0.22 (so NESTED SELECT doesn't work).

I understand that there is a MAX function for getting the latest date but this seems to require GROUP BY, and I don't require a group of results.

I have vainly been trying things like this:

SELECT selection_ID, user_ID, visit_date, period_of_day FROM visits WHERE visit_date = visits.MAX(visit_date)

View Replies !
Asking The Latest Added Lines From MySQL
How do i ask the latest added information in a table from MySQL, and display it? I want this to display the latest topics on my forums. And let it display the latest articles and scripts.

View Replies !
Query For Displaying Results Except Latest
So I'm looking for a way to pull the results from the database showing all the records EXCEPT for the latest one i.e. if there are 30 recordsets I only want to show numbers 1-29.

View Replies !
Selecting Latest Posts With Titles
I saw this on the big bad thread of MySQL Best Practices. It is precisely the problem I've got, but doesn't offer any answers.

select f.name
, max(dateposted)
, fp.title
from forum f
join forumpost fp
on fp.forum_id = f.forum_id
group
by f.name

Quote:

the user who wrote this query mistakenly assumes that fp.title will contain the title of the latest post from that forum. it will not. according to the mysql manual, "The server is free to return any value from the group, so the results are indeterminate unless all values are the same".



View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved