mysql

mysql, alter column remove primary key and auto incremement

Hi, I'm changing my mysql db table from an id (auto) to a uid. ALTER TABLE companies DROP PRIMARY KEY; ALTER TABLE companies ADD PRIMARY KEY (`uuid`); This is the error I get.. [SQL] ALTER TABLE companies DROP PRIMARY KEY; [Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key Wh...

MySQL Forms Authentication Hashed password problem

I am trying to use the ASP.NET forms authentication service with the MySQL connector version 6.3.2. I was able to get it working using cleartext passwords but unable to get hashed passwords working. Here is a snippet from my machine.config file <system.web> <membership defaultProvider="MySQLMembershipProvider"> <providers> ...

mysql complex query help please

I want to select all rows from Table 1 WHERE there is smith in column1 or column2 AND status 1. IF there is smith in column 1, then select the value from column 2, and if there is smith in column2, then select value in column 1 of the row. Then select all the rows from Table 2 WHICH contains that value in column1 or column2 of table 2, ...

Dump tables from database in mysql?

How can I dump each table in database in separate file with that table name? ...

MacOS X Error when installing python MySQLdb

Hi all, I am trying to install python mysqldb in my mac but I got the following errors. For mysql I am using the one that is bundled with MAMP. Thanks! here is the error message: running build running build_py copying MySQLdb/release.py -> build/lib.darwin-8.11.1-i386-2.3/MySQLdb running build_ext building '_mysql' extension gcc -fno-...

Searching a mySQL database

Hi guys, I am storing a bunch of user ID's inside of a mySQL database along with other data relative to each uid, but now I would like to implement a check in the beginning of the program which basically goes like so, if the user already exists, get the specified fields for that specific user and assign them to variables, else return nul...

Making a row inactive in MySQL

Is it possible to make a row in MySQL inactive? So this row isn't used in the results of queries anymore? My client wants to keep the deleted members exists in the database, but I don't want to edit all the queries to check if the member is deleted or not. Or is there an easy way to move the entire row data into another "inactive" tabl...

How to optimize this mysql query - explain output included

This is the query (a search query basically, based on tags):- select SUM(DISTINCT(ttagrels.id_tag in (2105,2120,2151,2026,2046) )) as key_1_total_matches, td.*, u.* from Tutors_Tag_Relations AS ttagrels Join Tutor_Details AS td ON td.id_tutor = ttagrels.id_tutor JOIN Users as u on u.id_user = td.id_user where (ttagrels.id_tag in (210...

Using SELECT DISTINCT in MYSQL

Been doing a lot of searching and haven't really found an answer to my MYSQL issue. SELECT DISTINCT name, type, state, country FROM table Results in 1,795 records SELECT DISTINCT name FROM table Results in 1,504 records For each duplicate "name"... "type", "state", "country" aren't matching in each record. Trying to figure out ...

MySQL: applying a random sort on multiple columns

Hello. In order to have a well scrambled table (for a psychological experiment), I'd like to sort each column of my array by RAND(). Althrough this code works: SELECT Sort.Variable1, Sort.Variable2 FROM Sort ORDER BY Variable1, Variable2 ASC LIMIT 0 , 30 replacing "ASC" by "RAND()" make the query fail. Can someone give me an advice (e...

How to output the number of times data occurs using SQL?

Given the following data: visit_id 1 1 1 2 3 3 4 5 is it possible using only sql (mysql's dialect actually, and no loops in another programming language) to output: total visits number of visitor ids 1 3 2 1 3 1 i.e. to break down the data into the ...

Order by field with SQLite

Hello, I'm actually working on a Symfony project at work and we are using Lucene for our search engine. I was trying to use SQLite in-memory database for unit tests (we are using MySQL) but I stumbled upon something. The search engine part of the project use Lucene indexing. Basically, you query it and you get an ordered list of ids, w...

MySQL Set AutoIncrement "Ad Hoc"

Is there a way to set mysql's auto_increment to a certain integer in an "ad hoc" way - for example, N of the latest rows have been deleted in a table, so the primary key/auto_increment is N off from the actual # of rows? Is there a way to set the auto_increment to the right number, or to manually set it? This seems common, so I believe...

MySQL select, between, AND, OR clause and query problem

I have a table named item with two attributes (code and name). Now i want to group them in the following way: group a: code between (5300 and 5310),(7100,7200),(8210,8290) group b: code not between (5300 and 5310),(7100,7200),(8210,8290) How can i do it using MySQL query? ...

Can a base64 encoded string contain whitespace?

Might a base64 encoded string contain whitespace? Specifically, could it contain whitespace at the end of the string? PS. I'm thinking about the whole "MySQL will trim trailing whitespace when storing strings in VARCHAR fields" here ;-) ...

How to do 'grading' in pure (i.e. ANSI) SQL

I have a table that looks something like this: CREATE TABLE student_results(id integer, name varchar(32), score float); Lets make the following two assumptions: assume that the score goes from 0 to a maximum of 100. assume that I want to grade students in 'step sizes' of 10 so I want to apply the following grading: Score Gra...

mysql,select query ,and or clause problem

i have a table named item with four attribute name,code,class,value now i want to group them in following way: group a: name='A',code=11,class='high',value between( (5300 and 5310),(7100 and 7200),(8210 and 8290)) group b: name='b',code=11,class='high',value between( (1300 and 1310),(2100 and 2200),(3210 and 3290)) how can i do it? ...

Maximum size of row in InnoDB table for text datatype in mysql 5.0.77.

The maximum size of a row in a MyISAM table is 65,535 bytes fro text datatype. What is the maximum size for InnoDB table in mysql 5.0.77. ...

Any tool to convert mysql store procedure to ms sql server store procedure?

Hello all, I have to migrate database from mysql to ms sql server 2005.I imported table successfully, now i need to convert store procedure written in mysql to ms sql server 2005.i need to convert a ton of sp so manual conversion is a tedious task, is any tool or simple way to convert sp of mysql to sql server 2005. ...

date_format in mysql select statement

Hi, I have date stored in my mysql table as "2010-01-01 01:01:01" but when i query the date with date_format command like DATE_FORMAT( date_created, '%%m-%%d-%%y (%%h:%%i %%p)' ) as cdate I am getting a converted date basing on mysql system timezone.. i.e. few hours difference.. for that i have used query : "SET GLOBAL time_zo...