mysql

PHP, MySQL and "sleeping" connections

Hi Everyone, I am running a web service powered by PHP/MySQL and recently noticed a strange issue. When I run "show full processlist;" SQL command via SSH terminal, I notice several "sleeping" connections: | Id | User | Host | db | Command | Time | State | Info | +-----------+---------+-----------+...

How to use Case Statement

Using C#.Net and MYSQL I want to use a CASE Statement like SQL Query SELECT vehicleno, brandname, CASE WHEN inexpire < 0 THEN 'Expired' ELSE inexpire END AS inexpire FROM (SELECT Concat(plateno, vehicleno) AS vehicleno, brandname, Datediff(inedate, Curdat...

Can I do this with MySQL or do I need to get PHP involved?

Hi, I have two MySQL tables with a similar structure. i.e. Table_A - Col1, Col2, Col3, Col4, Col5 Table_B - Col1, Col2, Col3 I need to run a query that says something like: SELECT * FROM Table_A WHERE (Table_A.Col1 DOES NOT EXISTS in Table_B.Col3 AND Table_B.Col2 = 'A') AND Table_A.Col5 = 2 etc... So basically I need to select ev...

insert sql statement into mysql database like common string?

I wrote a logger function and it inserts "insert and update queries" to database. altough I apply "mysql_real_escape_string" to the sql stament, I cannot insert it to the database. any suggestion please? ...

prevent duplicate entry data still no function

dear all. i have tried to prevent the duplicate data at my project. but until now it still make duplicate. i try this code but still not work: $cek_user= "SELECT Model, Serial_number, Line FROM inspection_report WHERE Model='".$Model."' AND Serial_number='".$Serial_number."' AND Line='".$Line."'"; $cek_data=mysql_num_rows($cek_user)...

How to enter DOB randomly for each row in a table in in SQL?

Error SQL query: UPDATE `wfg_db`.`employee` SET `DOB` = (DECLARE@mm INT DECLARE@xm INT SET @mm =1 SET @xm =13 DECLARE@md INT DECLARE@xd INT SET @md =1 SET @xd =29 DECLARE@my INT DECLARE@xy INT SET @my =1900 SET @xy =2009 SELECT CAST( CAST( ( @xm - @mm ) * RAND( ) + @mm AS IN...

Need help: Date format

I have birth date data stored in Mysql table as below: id firstname middlename lastname birth --------------------------------------------- 1 Harry Chandra Sihombing 1999-12-14 2 Janice Mona Sihombing 2010-04-20 . ... ... ... ... How can I create a search function to collect data from the ta...

MySQL: Help with script needed

CREATE TABLE `photos` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `photo` varchar(255) NOT NULL, `hotel_id` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=23061 DEFAULT CHARSET=utf8 So, i have table 'photos.' Now i want ALTER this table and add column 'type'. ALTER TABLE photos ADD COLUMN type varcha...

MySql set nocount on

SET NOCOUNT ON equalent function in MySql? ...

When to use What Storage Engine in the Real World (MySQL)?

When to use What Storage Engine in the Real World (MySQL)? I Know MyISAM is good for Full Text Searches and InnoDB is good for Transactions/Referential integrity but What do you use When as there are so Many Storage Engines and Why in the real World. I guess what i'm after is a discussion of the various Storage Engines in Mysql so i ca...

how to skip lines of a csv file while using LOAD DATA command?

hi, i'm using sql command load data to insert data in a csv file to mysql database. the problem is that at the end of the file there's a few line like ",,,,,,,,,,,,,,,,,," (the csv file is a conversion of an excel file). so when sql get to those lines he send me : #1366 - Incorrect integer value: '' for column 'Bug_ID' at row 661. the ...

MySQL Error in multiple table UPDATE

Here is my query: UPDATE TBL_LABELS SET TMP.column_value = LBL.label_desc, TMP.info_value=LBL.helptext FROM TBL_LABELS TMP INNER JOIN hh_label_mast LBL ON TMP.column_name=LBL.lbl_id WHERE page_id in(as_page_id ,'HHGENPGID') AND lang_cd= as_langcd; While executing this I am getting an error like "right synta...

How to set SQL select in Google SQLDataSourceServlet

Hello I wonder if anyone can help? I'm trying to use part of Google's Visualization API as shown here: Google TableQueryWrapper To get data from a MySQL database table. I have mapped the URL in the .html shown in this example to my application which calls a servlet provided by Google as follows: public class SQLDataSource_Servlet ext...

query to ignore first 2 rows

i have a query to fetch 100 rows of events ordered by timestamp. i want to ignore top 2 entries from the result set. The problem is that there is no criteria match (simply to ignore first 2 rows). i am using pager (drupal) which results 10 events per page. If i process it after fetching 10 rows i lost 2 entries (first page contains onl...

PDO select query error

I am trying to run this simple SELECT query using PDO::MySQL, but it does not return a value, as you can see from the dump $row returns false, which means there was an error. The database connection works, as I'm writing to the database a few lines further down Sql query is correct Can someone see the bug in this code? If you can I'd ...

MySQL syntax error in SELECT query

My code: $fileid = $_GET['imgid']; $fileid = (int)$fileid; //id is int type in photos table require 'database.php'; //get the image sourc name $q = "SELECT src form photos WHERE id='$fileid'"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if ($result) { $row = $result->fetch_object(); $filename = $row->src; ...

Cannot modify header information - headers already sent by error

my code- if ($result) { $row = $result->fetch_object(); $filename = $row->src; $q = "delete from photos WHERE id=$fileid"; $result = $mysqli->query($q) or die(mysqli_error($mysqli)); if ($result) { $filepath = "./images/"; if(fileDelete($filepath,$filename)) { echo "success"...

MYSQL : 1336 : Dynamic SQL is not allowed in stored function or trigger

Hi, Is there any fix for the below issue, in the newer versions, i have checked the same in 5.0.45 1336 (0A000): Dynamic SQL is not allowed in stored function or trigger Thanks, Bobin ...

php report generator

I was wondering is there any report making tools in php for MYSQL database? Threr are crystal reports for MS-SQL server and Oracle has its own report making tools. But i am finding difficulty making reports in php where i want to show header and footer for every page and it will show total pages and nevigation keys to show reports page b...

increase performance while retrieving thousand of record from mysql

I have one table that contain more that 40 thousand record when I retrieve record that satisfy particular condition it takes so much time. Is there any solution to increase performance ? ...