Some reports are erroneous because the timestamp didn't update at a certain moment. I found that it is because of a Bug #9435.
I read the details but not able to find information on how to fix it. Please help.
I'm trying to get a count of records matching certain criteria within a subset of the total records. I tried (and assumed this would work)
SELECT count(*)
FROM records
WHERE status = 'ADP'
LIMIT 0,10
and I assumed this would tell me how many records of status ADP were in that set of 10 records. It doesn't - it returns, in this case 30, which is the total number of ADP records in the table.
How do I just count up the records matching my criteria including the limit?
By default it's like this:
select * from main_table where match(col1,col2) against('search_item');
but what I want to fetch is the reverse,
say,I've restored all the search_item(1000 records,for example),
and I want to see which of them matches a specified row in main_table.
Is that doable?
Somewhat new to SQL queries and I need a little help with my join.
I am supplied with gid
For each of these I need to grab name from table wp_ngg_gallery
then join in table wp_ngg_pictures and grab field filename limit 1 order DESC by field imagedate
Anyone able to help?
How can I translate this 2 queries in postgresql ? :
.
CREATE TABLE example (
id int(10) unsigned NOT NULL auto_increment,
from varchar(255) NOT NULL default '0',
message text NOT NULL,
lastactivity timestamp NULL default '0000-00-00 00:00:00',
read int(10) unsigned NOT NULL,
PRIMARY KEY (id),
KEY from (from)
) DEFAULT CHARSET=utf8;
.
SELECT *
FROM table_1
LEFT OUTER JOIN table_2 ON ( table_1.id = table_2.id )
WHERE (table_1.lastactivity > NOW()-100);
Its been a while since I updated my pagination on my web page and I'm trying to add First and Last Links to my pagination as well as the ... when the search results are to long. For example I'm trying to achieve the following in the example below. Can some one help me fix my code so I can update my site. Thanks
Previous First 1 2 3 4 5 6 7 ... 199 200 Last Next
I currently have the following displayed using my code.
Previous 1 2 3 4 5 6 7 Next
Here is the part of my pagination code that displays the links.
if ($pages > 1) {
echo '<br /><p>';
$current_page = ($start/$display) + 1;
if ($current_page != 1) {
echo '<a href="index.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
}
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="index.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo '<span>' . $i . '</span> ';
}
}
if ($current_page != $pages) {
echo '<a href="index.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
}
echo '</p>';
}
I've done something like this in order to use on duplicate key update:
CREATE UNIQUE INDEX blah on mytable(my_col_to_make_an_index);
and its worked just fine. I'm just not sure what the purpose of the index name is -- in this case 'blah'. The stuff I've read says to use one but I can't fathom why. It doesn't seem to be used in queries, although I can see it if I export the schema.
So ... what purpose does the index name serve? If it helps the line in the CREATE TABLE ends up looking like:
UNIQUE KEY `clothID` (`clothID`)
I would like to rid new entries into my database of Latin-1 characters and just allow UTF-8. I plan to Alter table and make the following changes:
Charset: latin1 - utf-8
Collation: latin1_swdish_ci - utf8_general_ci
The table in question has 1 million rows. Is this a good idea? What are the risks of doing this? What happens to data that I try to input that is not in utf-8? What happens to data that has been previously entered that is not utf-8?
The following procedure gives me an error when I invoke it using the CALL statement:
CREATE DEFINER=`user`@`localhost` PROCEDURE `emp_performance`(id VARCHAR(10))
BEGIN
DROP TABLE IF EXISTS performance;
CREATE TABLE performance AS
SELECT time_in, time_out, day FROM attendance WHERE employee_id = id;
END
The error says "Unknown table 'performance' ".
This is my first time actually using stored procedures and I got my sources from Google. I just cant figure out what I am doing wrong.
how do I order this result??
$range = 5; // you'll be selecting around this range.
$min = $rank - $range;
$max = $rank + $range;
$limit = 10; // max number of results you want.
$result = mysql_query("select * from table where rank between $min and $max limit $limit");
while($row = mysql_fetch_array($result))
{
echo $row['name']." - ".$row['rank']."<br>";
}
I am working on an in-house, iOS app that will need read-only access to a SQL Server with multiple databases. I know the stock answer here is "write some web services", but I'd like a solution that is self-contained. Is there any way to directly connect to a SQL Server database from an iOS application? I'm thinking something like a basic ODBC connection.
I've seen a lot of users asking this question, but very few answers other than "write a web service." Is that really the only way?
I want to make a insert into 2 tables
visits:
visit_id int | card_id int
registration:
registration_id int | type enum('in','out') | timestamp int | visit_id int
i want something like:
INSERT INTO `visits` as v ,`registration` as v
(v.`visit_id`,v.`card_id`,r.`registration_id`, r.`type`, r.`timestamp`, r.`visit_id`)
VALUES (NULL, 12131141,NULL, UNIX_TIMESTAMP(), v.`visit_id`);
I wonder if its possible
$sql = "SELECT # FROM users WHERE onduty = 1 AND loc_id = '{$site}';";
$result = mysql_query($sql);
I simply want to test if this is true or false. If it returns 0 rows, I want next line to be something like:
if (!$result) { //do this; }
However, in my test, I am getting false when I know it should be true. Is this sound logic here?
(note, yes I know I should be using mysqli_query, that is not what I am asking here)
I just ran a command
update sometable set col = '1';
by mistake without specifying the where condition.
Is it possible to recover the previous version of the table?
Hi,
Please tell me how can I find the last word from any particular cell in excel sheet if cell contains multiple words or instructions.
For ex- The below string is in particular cell:
C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg
My requirement is to search only last word in that cell i.e. Blue hills.jpg
Your early response is highly appreciated!!!
I have a column using IDs that I want to sort by. It has ID values from 1 to 3. However, instead of just using ASC of DESC, I want to do a custom sort by 2, 3, 1. How do I make this happen?
Hi,
I have a small problem.
I am creating an appointment table where in the foreign key is patient id which is referenced from patient table.This table is for all registered patients.
there will be unregistered patients also, who will be seeking appointments.SO i just need to store the name,phone and few details.
I don't want to make these 2 as different tables.
So is there a way to skip the integrity check of foreign key when i ma inserting unregistered patient data
Hello,
I'm making a hit counter. I have a database and I store the IP and $_SERVER['HTTP_USER_AGENT']; of the visitors. Now I need to add a filter, so I can put away the hits, that are made by bots. I found out, that many bots usually keep some common words in the $_SERVER['HTTP_USER_AGENT']; , so I's like to make and array of words, that would keep the bot from displaying in the results.
Here is what I have now:
while($row = mysql_fetch_array($yesterday, MYSQL_ASSOC)) {
<-- Here I need a code, that would run through an array and check,
if it containts the keywords and if it doesn't ... just count++; --
}
Also if you know any other way of detecting and removing the bots from the results, I'd be verry thankful. Cheers
I'm currently storing various metadata about videos and one of those bits of data is the length of a video.
So if a video is 10 minutes 35 seconds long, it's saved as "10:35" in the database.
But what I'd like to do is retrieve a listing of videos by length (longest first, shortest last).
The problem I'm having is that if a video is "2:56", it's coming up as longest because the number 2 is more than the number 1 in.
So, how can I order data based on that length field so that "10:35" is recognized as being longer than "2:56" (as per my example)?
I have two product tables Product1 and Product2. There is a one 2 one mapping on the field ProductId.
What I want is to get all the product ids where the Product2.Exported field is false AND
Where the product ids that are in Product1 but not in Product2 table.
Right now I have two queries that I'm trying to mash into one.
SELECT ProductId FROM Product1 WHERE ProductId NOT IN(Select ProductId From Product2)
SELECT ProductId FROM Product2 WHERE Exported = 0
I have following data
UserID UserName LogTime LogDate
1 S 9:00 21/5/2010
1 S 10:00 21/5/2010
1 S 11:00 21/5/2010
1 S 12:00 21/5/2010
Need Output as:-
1 s 9:00 10:00 21/5/2010
1 s 11:00 12:00 21/5/2010
I'm trying to update some info into database but for some reasons it doesn't update. Also I'm not getting error in the server logs.
mysql_query("UPDATE `view_item` SET `item_number` = $item_number, `title` = $title, `price` = $price, `shipping` = $shipping, `location` = $location, `start_time` = $start_time, `end_time` = $end_time, `seller_userName` = $seller_userName, `seller_UserNum` = $seller_UserNum, `number_of_bids` = $number_of_bids, `picture_link` = $picture_link WHERE `item_number` = $item_number");