mysql

MySQL Tri-state field

I need to create a good/neutral/bad field. which one would be the more understandable/correct way. A binary field with null (1=good, null=neutral, 0=bad) An int (1=good, 2=neutral, 3=bad) An enum (good, neutral, bad) Any other It's only and informative field and I will not need to search by this. ...

Extract binary data from DB to file

How do I extract binary data from DB to file CREATE TABLE `mail_attachs` ( `attachid` int(15) NOT NULL auto_increment, `filecontent` longtext, PRIMARY KEY (`attachid`), ) ENGINE=MyISAM The binary data has been saved in the filecontent column. I want to extract the files and text saved in this column and save it to a file on th...

MYSQL PDO return type strange conversion

I have the following table definition in MYSQL CREATE TABLE IF NOT EXISTS `test_cases` ( `id` int(10) unsigned NOT NULL auto_increment, `exercise_id` int(10) unsigned NOT NULL, `author_id` int(10) unsigned NOT NULL, `input_1_value` varchar(255) default NULL, `input_2_value` varchar(255) default NULL, `input_3_value` varchar(...

Is there a way to change the MySQL Database Engine with Doctrine Migrations

Hi there, does anyone know a way to write a Doctrine migration to change the Table Engine of a MySQL Database from MyISAM to InnoDB? Can this be managed via Migrations or do I have to this the old way via SQL-Statements? ...

Change Permanently Session System Variable in MySQL

I added this line to my.ini wait_timeout=2000000 When I type show global variables It prints wait_timeout=2000000, but when I type show variables It prints wait_timeout=28800 I can set with set wait_timeout=2000000 But I do not want to set it all the time manually. Do you have any suggestion to set permanently session sys...

mysql how to get the type of data in a varchar field using query. as it can hold any datatype as string.

Hi, The reason for a second sentence in my question " as it can hold any datatype as string." is to make the question more specific from the view of it so that people will really get the actual picture before going to the answers. i have asked this question after posting and getting responses to this question. according t...

mySQL Group By question

Hi how do i group this data: **Date** **Day** **DURATION** **IDSTAFF** 21-09-2010 Sun AM 1 22-09-2010 Mon AM 1 21-09-2010 Sun PM 2 22-09-2010 Mon PM 2 So it will become like this? **Date** **Day** **DURATION** **IDSTAFF** 21-09-2010 Sun AM 1 (am),2 ...

MySQL Version Control

Hi There I am wanting to do some basic version control with my mysql database structure. I am not worried about the contents of the database, I just want to track any new tables added, tables altered, and tables deleted. Is there a simple application that could do this all automagically? (Needs to run on a Linux envirnment) I have loo...

packet of queries - MySQL

Hi, is there a way to send packet of queries in 1 query to mysql using c# ? i mean i got 13 selects, they are not related, so cant union them, they get diffrent type of data. Now i got dbconn, 13x select, dbclose, its not a problem when it works over lan, but over internet it sometimes takes to slow cos of latency (13x select and recive ...

first 3 digits of a string

What is the best way to know the first 3 digits of a string? I have written a function for the same. It is working as expected, but I will like to know if there is a better way to do this. mysql> select areacode_fun('233434535'); +---------------------------+ | areacode_fun('233434535') | +---------------------------+ | 233 ...

MySQL: Multiple Photos and Videos for News with Joins

I want multiple photos and multiple videos, the main problem is that I can't get them inline if I don't use joins. So for example, I get 2 photos a video and again a photo. I have a parent news table and 2 secondary table news_photos and news_videos and I want to get in one query the photos and videos for the news. Is this somehow pos...

how to create SSL for MySQL in Windows

how do i create SSL for MySQL in Windows? i have downloaded a OpenSSL but don't know how to get it work in Windows since all the commands are in UNIX shell. help anyone? ...

how to do this in MySQL

I need a table which has two columns: First column have an ID Second column have an ID to. like two person who are friend then first's ID in first and second's ID in second but if I need to check the first user's friend then I need to check by two condition check the friend by first column check the friend by second column What...

a system that record and count user logged in

hi again everyone i am trying to build a log system that would record how many times a particular user logged in to my system, my temporary logic is this way: every time a user logged in i would extract these fields user_id counter time(m/d/y) << daily log and store those inside a table in the database the action would be this way...

Error Code : 1324 Undefined CURSOR: OPEN

hey guys,i'm new to mysql.here i wrote a procedure that error occured: DELIMITER $$ USE `flower2`$$ DROP PROCEDURE IF EXISTS `test`$$ CREATE PROCEDURE `test`() BEGIN DECLARE soldcount INT; DECLARE goodsid INT; DECLARE not_found INT; DECLARE curGoodsId CURSOR FOR SELECT goods_id FROM ecs_order_goods; DECLARE curSoldCount ...

Why is MySQL auto_increment skipping numbers.

We are running an import of an existing product table into a new table of our own. The import script we've written runs perfectly and inserts the right amount of rows (6000 or so). However, after the import the next auto incremented primary key/id is 1500 entries (or so) above the number of rows in the table. We can't understand why MyS...

Sphinx Building Index Improvement

Hey guys, I have a question about Sphinx. I use Sphinx to index the full-text searches for my sites, and it works like a dream. At this point in time it takes about 30 minutes to create the indexes for all my databases. This is fine as I only run the indexing script once every hour. But the databases are getting bigger quickly, and soon...

Email already sent?

Hi, Can someone explain a simple solution using MySQL and PHP how to check if an email has been sent already, stopping duplicates for users. I have a basic script, but it's not working for some reason - http://pastebin.com/k7yiQahb It inserts into the table the following: feed_id, recipient_id, issent 0, 0, Y Regards ...

How many times you can write Select Inside Select query in Mysql?

When I was studying MySQL I have been asked by my Teacher to find out that how many times we can write Select query inside Select query At that time I found the answer practically. ...

InnoDB and joining tables - problem with this...

I have two databases, tvguide and episodes1. Both are InnoDB, and I use Phpmyadmin to edit them. I tried creating a foreign key between the "episode" field of episodes1 and tvguide, and this error message came up: Error creating foreign key (check data types) : episode How can I fix this and ensure both tables join? I have InnoDB se...