I have table with advertisement in MySQL. I would like to rotate banners by order (NOT RANDOM). What function or mechanism I need to SELECT advertisement from MySQL table to show it in order, like 1, then 2, then 3 ... then again 1,2,3... ?
When I try to put a value into a DATE field which is invalid, MySQL seems to use 0000-00-00 instead. Is there a way I can do this "check" without updating a DATE field? And to do it from for example PHP?
Like, is there a way I can query the MySQL server and ask "Hey, is this DATE, TIME or DATETIME valid to you?"
Or is there maybe an even better way of doing it?
Hi all,
I have the following table.
mysql> select * from consumer2;
SERVICE_ID SERVICE_TYPE CONSUMER_FEEDBACK
31 PRINTER 1
32 PRINTER -1
33 PRINTER 0
34 PRINTER -1
35 PRINTER 0
31 PRINTER 0
32 PRINTER 1
35 PRINTER 1
31 PRINTER 0
From the above table i need to select the bottom 4 values using mysql
i need to get the output as follows
SERVICE_ID SERVICE_TYPE CONSUMER_FEEDBACK
31 PRINTER 0
32 PRINTER 1
35 PRINTER 1
31 PRINTER 0
Please help me.Thank u in advance.
I'm porting some stored procedures from Informix to MySQL, but I have two stored procedures on Informix that have same name and different parameters.
In MySQL, I can't create two SP with the same name, and also can't create a SP with default values in parameters.
so, do someone out there know any hackery or black magic that may help me solve this problem?
thanks.
I am Looking for a Function that insert "Any" form values to mysql, update or delete.
(not OOP)
I have found a function here:
http://tr.php.net/manual/en/function.mysql-query.php
Thanks in advance
on a test for Java-MySQL-Restlet application, I write to database at 4reqs/second for 120 seconds.
In this write I insert a row that has foreign key which has the same value for all rows, and this exception occurs:
Could not recover transaction. Original exception follows. com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'idPxxx' at row 1
Only 5% of requests fails to this exceptions, others works.
Regards
This question is about Mysql Binary logging.We need to move the Binary logging to a different hard disk . What is the configuration change required in Mysql?.Currently Binary logs go into the same folder as the ibdata and there is a replication slave running which needs the binary logs
when I input
mysql -u root -p XXXX dbname < c:/filename.sql
alway get this error "error 1064 <42000:" you have an error in your SQL suntax; check the manual that corresponds to your MySql server version for the right syntax to use near .....
what is wrong with this statement?
I'm trying to select the order total sum ($) and invoice count over a 5 day period in a single query. I can't seem to get this to happen though. The current query I have is here...
SELECT
COUNT(id) as invoice_count,
SUM(orderTotal) as orders_sum,
UNIX_TIMESTAMP(created) as created
FROM ids_invoice
WHERE DATE_ADD(created, INTERVAL +1 DAY)
AND userId = '.$userId.$whereSql
I'm not entirely sure DATE_ADD is the right function I'm looking for
I'm fairly new to mysql date functions so perhaps I just missed the function I needed when going through mysql docs.
My import of sql via the mysql console is rather slow and as our sql file is increasing every day I would like to know if there are any alternatives on how to import a sql file faster.
Changing to oracle or other systems is no option, the configuration has to stay the same.
Currently the sql file is: 1.5 Gb
I'm on Wamp with Apache 2.2.14, PHP 5.2.11 and MySQL 5.1.41.
Any suggestions?
I've installed mysql on several macs and on one of them mysql is not in the path. If I export it it shows up in the path correctly, but upon reboot, disappears.
What should I do to get the machine to keep it in the path and what are the machines that DO have it in their path doing differently?
Any thoughts appreciated.
I use Visual Studio 2008, MySQL 5.0.90,Qt 4.6.3 and C++
I try connect MySql but it gives this error messages.
Driver not loaded.
I am new programmer. How cann I solve this problem? Thank a lot.
I have two table in mysql
one tbl_a which has one int column id,
second tbl_b which has one column song_ids in which data stored seapated by comma like 1,2,3,4
i want to select all id like this
select * from tbl_a where id in (select song_id from tbl_b)
but its giving me no record as its varchar
HOW to do it in mysql
Using an array like this:
$data = array
(
'host' => 1,
'country' => 'fr',
)
I would like to create a MySQL query that uses the values of the array to form its WHERE clause like:
SELECT *
FROM table
WHERE host = 1 and country = 'fr'
How can I generate this query string to use with MySQL?
Anyone knows how to implement XXTEA in MySQL?
For example - SELECT xxtea_encrypt('text here', 'key here');
possible implementation is by creating a FUNCTION in MySQL using CREATE FUNCTION statement, e.g.
CREATE FUNCTION xxtea_encrypt
XXTEA Procedures here...
RETURN encrypted string
Thanks & Best regards
How to fetch the first two rows from Mysql DB using Mysql PHP function? Is there any function which can give me first 2 or 3 rows from the select query we fired?
I have this code (mySql 5.1.36)
CREATE TRIGGER problem_description AFTER INSERT ON problem_description
FOR EACH ROW BEGIN
INSERT INTO log SET Id=NEW.Id,user_name=NEW.user_name;
END;
and have this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3
i have oracle background,
i am looking for oracle v$sql view in mysql in order to see last queries has been run on all sessions in database
how can i see this in mysql ?
I ran this using MySql and it appears to not like TEXT. With SQL server i use nvarchar(max) What should i use in MySQL? In other tables some fields will be descriptions and may be long so ATM i am thinking fixed length is bad.
create table if not exists misc_info (
id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
key TEXT UNIQUE NOT NULL,
value TEXT NOT NULL)ENGINE=INNODB;
After a reinstall, all of the old data still shows inside the MySQL/data folder, but is not actually loaded into the database.
Is there any way to have MySQL scan it's data folder and / or reimport the old folders it has from its previous install?
[Some data was changed after the last backup / export - partially my fault - so I would rather it recognize the folders rather than reimporting the SQL files.]
I am using C# code for inserting record and datetimepicker control for Date
I want to insert Date like 24-05-2010 in MySQL Database
What Datatype i have to use for that in MySQL table
and how to right insert query for to insert date?