mysql

Getting value depedning on two boolean attrinutes.[Nested ifs]

I have two fields start_time end_time -> can be null Now, depending on this I needs to differentiate between three states Scheduled in future, Currently running Completed in past Since mysql IF operator can not be nested, (Or I cant find an easy way to nest them), I cant find how to get the three state status. ...

Need help with this SQL

Hi guys, I am very very new to mysql. I am trying to execute the following query. update share set holder = 22 where SHARE_ID IN (select SHARE_ID from SHARE WHERE holder=1 LIMIT 10) When I try to execute the above query I am getting this error #1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' ...

Setting column length of a Long value with JPA annotations

Hi, I'm performing a little database optimisation at the moment and would like to set the column lengths in my table through JPA. So far I have no problem setting the String (varchar) lengths using JPA as follows: @Column(unique=true, nullable=false, length=99) public String getEmail() { return email; } However, when I want to d...

tomcat/jdbc/mysql: can insert ÿ(U+00FF) but not Ā (U+0100)

hi, my setup: mysql 5.1 show variables: | character_set_client | utf8 | character_set_connection | utf8 | character_set_database | utf8 | character_set_filesystem | binary | character_set_results | utf8 | character_set_server | utf8 ...

PHP error problem.

I get the following error on line 8: Undefined index: privacy_policy which is $privacy_policy = mysqli_real_escape_string($mysqli, $_POST['privacy_policy']); I was wondering how can I fix this problem? Here is line 8. $privacy_policy = mysqli_real_escape_string($mysqli, $_POST['privacy_policy']); Here is the PHP. if (isset($_POST['s...

How i can design a cache system using PDO and memcached?

Hi, I'm using PDO for connect to the database in a system where I want implement memcached. I don't know what keys use for caching the results because I can't get the string of the final query with PDO (because the prepared statements). Any good idea for resolve this? Thanks in advance. ...

memory leak in php script

Hi, I have a php script that runs a mysql query, then loops the result, and in that loop also runs several queries: $sqlstr = "SELECT * FROM user_pred WHERE uprType != 2 AND uprTurn=$turn ORDER BY uprUserTeamIdFK"; $utmres = mysql_query($sqlstr) or trigger_error($termerror = __FILE__." - ".__LINE__.": ".mysql_error()); whil...

Writing a CSV file for Mac users with PHP

I use a generic algorithm to write CSV files that in theory works for the major OSes. However, the client started to use Mac a few weeks ago, and they keep telling me the CSV file cannot be read in Microsoft Excel 2008 for Mac 12.2.1. They have their OS configured to use "semicolon ;" as list separator, which is exactly what I am writin...

mysql select query problem

i have a form that has a multiple select drop down. a user can select more than one options in the select. the name of the select is array[]; using php I call implode(",",$array) in mysql db, it stores the field as a text in this format "places"= "new york, toronto, london" when i want to display these fields i explode the commas. I am ...

Read a text file and transfer contents to mysql database

I need a php script to read a .txt file. The content of the text file are like this: data.txt 145|Joe Blogs|17/03/1954 986|Jim Smith|12/01/1976 234|Paul Jones|19/07/1923 098|James Smith|12/09/1998 234|Carl Jones|01/01/1925 These would then get stored into a database like this *DataID |Name |DOB * 234 |Carl Jones|01/01/192...

Can't store Data URI to database without stripping + characters

I am trying to grab a reference to images with src's in URI scheme. An example would be the images on google.com/news. if I alert(escape(saveObj.image)); I get something like below: data%3Aimage/jpeg%3Bbase64%2C/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQ...

Delete, Truncate or Drop MySQL question

Hi Everyone! I am attempting to clean out a table but not get rid of the actual structure of the table, i have the following columns: id, username, date, text the id is auto incrementing, I don't need to keep the ID number, but i do need it to keep its auto-incrementing characteristic. I've found delete and truncate but I'm worried one...

How do I join these queries?

query1: SELECT category.id, category.name, category.level, category.description, category.cat1, category.cat2, category.cat3, category.cat4, category.pri_color, category.sec_color, category.last_report AS report_id FROM category, reports_category_layout WHERE category.id = reports_category_layout.catID AND reports_category_layout.site_...

Is there any difference between SQL running in code vs the MySQL command line?

I have a SQL update statement I am running from inside a PHP program. It is prepared and then executed. When I run it in PHP, it reports a constraint violation. When I run the exact same statement from the command line (which I am getting via dBug()), it works with no errors. This sounds impossible, so I keep looking for differences ...

SQL: count days in date range?

I have a query like this: SELECT COUNT(*) AS amount FROM daily_individual_tracking WHERE sales = 'YES' AND daily_individual_tracking_date BETWEEN '2010-01-01' AND '2010-03-31' I am selected from a date range. Is there a way to also get the total days in the date range? ...

MySQL query String contains

Hello. This may sound easy, but I've been trying - in vain, apparently - to figure out how I can make a query with MySQL that checks if the value (string $haystack ;) ) in a certain column contains certain data ( $needle ;) ), like this: mysql_query(" SELECT * FROM `table` WHERE `column`.contains('{$needle}') "); In PHP, the function...

Use a stored procedure parameter for unit parameter of DATE_SUB

I would like to know if it's possible to pass a parameter to a mysql stored procedure and use this parameter as the unit parameter of the DATE_SUB function. It seems that the unit parameter is a reserved word so I don't know if there's a type for unit. Exemple of what I'm trying to do : DELIMITER $$ DROP PROCEDURE IF EXISTS `test` $$...

Display Events on PHP Calendar

Hi, I would like to ask if I have a table of events on my database, e.g. description | startdt | enddt event1 | 2010-04-01 10:00:00 | 2010-04-01 13:00:00 event2 | 2010-04-09 14:00:00 | 2010-04-09 18:00:00 event3 | 2010-04-30 11:00:00 | 2010-05-02 16:00:00 I have already created a php calendar, how can I dis...

Problem installing MySQL gem on Fedora

When I try rake db:migrate, I get the following error: The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! no such file to load -- mysql And when I try to gem install mysql Building native extensions. This could take a while... ERROR: Error installi...

MySQL get data from another table with duplicate ID/data

How to query data from table_1 which ID is not available on table_2 that has duplicate ID's. See example below. I want to get ID 5 and 6 of Table 1 from Table 2 Table 1 ------------- | ID | Name | | 1 | a | | 2 | b | | 3 | c | | 4 | d | | 5 | e | | 6 | f | ------------- Table 2 ------------- Table 1 ID | | 1 ...