mysql

How can I update just the date part of a timestamp?

I wish to update just the date part of the timestamp, I don't want to change the time part, I want to do this with mysql but don't know the function or right query to use. Please help, I am a newbie to mysql. ...

creating xml with php and 'if changed' option

Hi all, I am creating an address book xml feed from a MySQL database, everything is working fine, but I have a section tag which gets the first letter of the surname and pops it in that tag. I only want this to display if it has changed, but for some reason my brain isn't working this morning! Current code: <?php echo "<?xml version=...

mySQL Text search issue when text includes brackets

I'm having an issue working out how to identify specific movie titles, when extra information is included after the title itself. At the moment, I have a title such as: Sherlock Holmes [2010] In the database it's something like: Sherlock Holmes (2010) or just Sherlock Holmes Currently I'm matching it by stripping off any square br...

PHP/Mysql Search - Case sensitive

Im using the following PHP and MySql to fetch rows from a table, $search_word=$_GET['search_word']; $search_word_new=mysql_escape_string($search_word); $search_word_fix=str_replace(" ","%",$search_word_new); $sql=mysql_query("SELECT * FROM tweets WHERE content LIKE '%$search_word_fix%' ORDER BY votes DESC LIMIT 20"); The 'content' fie...

fetchAll helper function using PDO

Suppose I have a function function fetchAll(){ $args = func_get_args(); $query = array_shift($args); $query = str_replace("%s","'%s'",$query); foreach ($args as $key => $val) { $args[$key] = mysql_real_escape_string($val); } $query = vsprintf($query, $args); if (!$query) return FALSE; $res = mysql_query($query); ...

How do I re-use reports on different datasets?

What is the best way to re-use reports on different tables / datasets? I have a number of reports built in BIRT, which get their data from a flat (un-normalized) MySQL table, the data which in turn has been imported from an excel sheet. In BIRT, I've constructed my query like this, such that I can change the field names and re-use the ...

Is there any MySQL Aggregate Function for "CONTAINS"?

Say I have this data set user | group --------+------- [email protected] | A [email protected] | B [email protected] | A [email protected] | B [email protected] | A [email protected] | B [email protected] | C I want to convert this into a table like this: user | IN_A | IN_B | IN_C --------+-------+-------+------- [email protected] | TRUE | TRUE | FALSE [email protected] | TRUE | FALSE | FALSE c@...

Converting a Mysql Result Object to Associative Array (CodeIgniter)

Hello, I'm trying to get a database query which is an object converted to an associative array, so that I can use it in the calendar class in codeigniter. This is my model: <?php class Get_diary_model extends Model { function getAllDiaries($year,$month) { $data = $this->db->query("SELECT day AND entry FROM diary WHERE m...

Is it possible to use different collations (per row) or to add your own collation in MySQL?

The problem A friend is developing a Swedish dictionary web application. One use will be for checking words in Scrabble games. The Swedish Scrabble rules (in Swedish) allow for example 'a' and 'á' to be treated as the same letter, but not 'u' and 'û' or 'y' and 'ü'. The Swedish collation rules (latin1_swedish_ci) think differently and t...

Mysql insert with foreign key referring to primary id

Let's say I hava a table object: id, primary key auto-increment obj_id, foreign key (object.id) val, integer Is it possible to insert a record with obj_id = id. Not having an error with foreign key constraint? Insert into object (val) values (123) ...

Display all values in a GROUP BY

How do I get all the values in a group by statement? mysql>select * from mytable; +------+--------+--------+ | name | amount | status | +------+--------+--------+ | abc | 12 | A | | abc | 55 | A | | xyz | 12 | B | | xyz | 12 | C | +------+--------+--------+ 4 rows in set (0.00 sec) mysql>sele...

How can I use column values as column names in MySQL

I have a table that looks like this: |date |category_id|val |2010-08-09|1 |2 |2010-08-09|2 |45 |2010-08-10|3 |1500 |2010-08-10|2 |4 I would like to select from this table, that each category id is a column so the end result looks like this: |date |1 |2 |3 |2010-08-09|2 |45 |NULL...

INSERT INTO SELECT,copy value+ 'string'

Hello, I need to copy a row .Copied row,I need to change value, this value + 'copy' I made this sql..but it's not work.. INSERT INTO prizes_i18n ( lang_id , translation_name , translation_desc , name , lang_path) SELECT prizes_s.lang_id , prizes_s.translation_name + 'copy' , prizes_s.translation_desc ...

Need lowest price in each region in a mysql query

Hi guys, I am trying to write up a query for wordpress which will give me all the post_id's with the lowest fromprice field for each region. Now the trick is these are custom fields in wordpress, and due to such, the information is stored row based, so there is no region and fromprice columns. So the data I have is (but of course cont...

How can I delete all the databases in my machine without deleting them one by one?

I want to delete all the databases in my Macbook pro. The number is more than 300 so I can't remove them one by one. How can I delete all the databases without deleting them one by one? ...

LINQ Generating Bad Query, Error Unknown Column (VB.NET MySQL)

I'm developing in MVC2 using VB.NET and MySQL and ran into a problem trying to convert a simple SQL query to LINQ. SQL Query: SELECT Location_Number, sum(Column1) as totalC1, sum(Column2) as totalC2 FROM MyTable WHERE year = 2010 and month = 8 GROUP BY Location_Number ORDER BY Location_Number LINQ Query: From r In MyTable _ Where...

Mixing RAND() and UNION gives random rowcount?

I was testing out a query to get a random integer in MySQL, and I noticed this behavior: mysql> SELECT FLOOR(0 + (RAND() * 5)) UNION SELECT FLOOR(0 + (RAND() * 5)) UNION SELECT FLOOR(0 + (RAND() * 5)); +-------------------------+ | FLOOR(0 + (RAND() * 5)) | +-------------------------+ | 1 | | ...

I no longer see the dolphin animation in MySQL Query Browser

I've become used to seeing the dolphin swimming animation when an operation is running in MySQL Query Browser. I'm currently using v1.2.13 and the animation (at the top right of the window) is not there. I can't find a setting in the toolbars or the 'Options' to enable/disable it. Am I missing a setting somewhere? Where has he gone,...

insert sql consumes long time in Hibernate

In my application I have two table, Group and Role, that are related between them with a @ManyToMany relationsheep. Since each Group can have many Roles and each Role can have many Groups. The first one: @Table(name = "groups") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class Groups { private Set<Role> ro...

Check for referential integrity break

Hi All, In my process, I do something like: SET FOREIGN_KEY_CHECKS = 0; LOAD DATA INFILE '/path/to/mytable.txt' INTO TABLE mytable; SET FOREIGN_KEY_CHECKS = 1; Now, I need to check that the data after this import is not breaking the referential integrity. I would like to do something like check database all foreign_keys; Is a simi...