mysql

Moving data from MyISAM to InnoDB - records count error

I've been trying to move some data from a MyISAM database table to a different InnoDB database. The method I used to do that was to Select into outfile from the MyISAM table and then LOAD DATA INTO the InnoDB. The tables don't match perfectly, but the InnoDB table looks like this Field | Type | Null | Key | Defau...

SQL: Can I INSERT some fields from variables other from another table

SQL Question I wonder if I can write a single sql INSERT statement to insert a row into a table where some of the fields come from variables and others come from another table. Currently I select from tableA, store the fields in variables and then insert them into tableB. In the following example I'd like to get field1, field2, and fie...

How to cast DATETIME as a DATE in mysql?

My query is this. I have a bunch of entries and i want to group them by date. But instead of having date in my database, I have a datetime field. What do I do? select * from follow_queue group by follow_date cast follow_date as date That's not working. Thanks! ...

"Access Denied" error after re-installing mysql on mac

I reinstalled mysql on my machine, and before that, deleted all the files. However, after the reinstallation, i tried running mysql, and got this error mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) I did not set any password, and in fact, running mysqladmin gives the same error as wel...

How to get Advanced Statistical Data from MySQL?

Hi, I have a very large MySQL database with a table having structure like this: In the exmaple, the DATE is in unix timestamp format. So it will need to be converted to normal US date format and this is just a few records from my DB. ID      DATE                REG_TYPE -------------------------------------- 1     1251917888         ...

How can I replace & with an ampersand in my database?

I have about 6k rows of data where we have & in various different rows. I'd like to replace this with an ampersand sign if possible. Can someone please tell me how to do this with mysql? Thanks ...

Handling Reoccurring Events in PHP/MySQL

Example 7.30pm, second Monday each month or 7.30pm, first & third Thursday each month. Basically I want a upcoming events list for the next month. How do I handle reoccurring events in PHP/MySQL? ...

LINQ to MySQL - what is the best option?

Has anyone used any of the utilities out there for LINQ to MySQL? Do you know which one is best? So far I know of LINQ for NHibernate, and DBLinq ...

mysql: how to sum 2 fields in the table and put the result in the 3rd field?

Hello lets say our table has the following structure col1 | col2 | col3 I want to sum col1 and col2 then update the col3 with the result Thanks ...

How can I calculate the PageRank for my small network?

Hello I have two tabled in my Mysql database table1 has the all webpages in my network | table1: (pages)| |----------------| | id | url | |----------------| table2 has two fields, which are the source page of the link and the destination page of the link |------------------------...

SQL: how do write the ORDER BY based on value within a group?

I have a table project issues updated 1 1 2009-09-03 1 2 2009-09-08 2 1 2009-09-12 2 2 2009-09-01 and I would like to sort so that the projects are sorted in descending order so that the project with the latest updated issue is first etc., but all issues of a project are kept together and the issues are in asce...

Sphinx + tokyo Tyrant + mysql

I'm looking at creating a full text search engine for one of my projects. We have a Mysql, Tokyo Tyrant and file documents that need to be indexed. I'm looking at Sphinx right now but I can't figured out if I can use it to index every document. I know it's possible to let Sphinx to use Mysql but I'm looking at a way to let Sphinx inde...

Insert Variables into a table which is selected from a PHP variable name

So, I want to insert some data into a MySQL table where the table name that the data is being put into is a PHP Variable. Something like this: $tablename = "databasetable"; $insert = mysql_query( "INSERT INTO '".$tablename."' (column1, col2) VALUES ('Blah', 'Blah') "); But that of course doesn't work, so I'm not sure what to do. B...

Select mysql query between date?

How to select data from mysql table past date to current date? For example, Select data from 1 january 2009 until current date ?? My column "datetime" is in datetime date type. Please help, thanks Edit: If let say i want to get day per day data from 1 january 2009, how to write the query? Use count and between function? ...

Getting unneccessary data from mysql database??? (php)

I have a database that has a users first and last name. Some cases i display the users full name, but in other cases i just show the first name. i have a function that gathers user information. within the function, i use an sql query to gather the first and last name, but i also concat the first and last name and label it full_name. Ex...

How to properly test query performance

I have a function that takes either an array of IDs or a singular ID as an argument. If an array is passed, it is imploded on comma to make the IDs query friendly. There is a query inside this function that updates the records for the IDs that were passed. The query is as follows: "UPDATE tbl_name SET enabled = 1 WHERE ID IN (" . $ID...

Using filesort to sort by datetime column in MySQL

hello, I have a table Cars with datetime (DATE) and bit (PUBLIC). Now i would like to take rows ordered by DATE and with PUBLIC = 1 so i use: select c.* from Cars c WHERE c.PUBLIC = 1 ORDER BY DATE DESC But unfortunately when I use explain to see what is going on I have this: 1 SIMPLE a ALL IDX_PUBLIC,DATE NULL ...

insert text field from MSSQL to MYSQL failed

I'm trying to income data from a MSSQL (2005) table to MYSQL (5) table, using SSIS, all fields insert correctly. Except one field that his type is TEXT in MSSQL to MYSQL TEXT field, and always this field is get NULL ! ...

SELECT only rows that contain only alphanumeric characters in MySQL

I'm trying to select all rows that contain only alphanumeric characters in MySQL using: SELECT * FROM table WHERE column REGEXP '[A-Za-z0-9]'; However, it's returning all rows, regardless of the fact that they contain non-alphanumeric characters. ...

Dynamic MySQL with local variables

How can I use dynamic SQL statements in MySQL database and without using session variables? Right now I have such a code (in MySQL stored procedure): (...) DECLARE TableName VARCHAR(32); SET @SelectedId = NULL; SET @s := CONCAT("SELECT Id INTO @SelectedId FROM ", TableName, " WHERE param=val LIMIT 1"); PREPARE stmt FROM @s; EXECUTE stm...