mysql

How to generate unique alphanumeric content in MySQL?

Say, values would be 1000-characters long. ...

generate a unique hash value which can be used as primary key in mysql thru php

I am using auto increment value for the inserts in my table. But is there any other way to generate a unique value (which is small enough and not GUID or UUID) in php to insert as primary key in mysql? Basically I want to get the value that is used as PK, but using auto increment I guess I cannot get the next auto increment value? Plea...

Validate Date at MySQL

How do you validate a date in MySQL ? In SQL Server, we have "ISDATE()" to validate whether the expression is a valid date. What function do we use in MySQL ? ...

mysql: Optimizing query w/ mixed-ascendency ORDER BY

I have a large table (~1M rows now, soon ~10M) that has two ranked columns (in addition to the regular data): avg_visited, a float 0-1 representing a %age popularity; higher is better alexa_rank, an integer 1-N giving an a priori ranking The a priori ranking is from external sources so can't be changed. Many rows have no popularity y...

MySQL auto increment plus alphanumerics in one column

I am new to MySQL coming from Oracle. I have a requirement to create a table with the primary key in one column but with the following format. X-A letter stating the country of origin e.g. S for Spain, Z for Zimbabwe e.tc (we have five countries of origins only) YYYYMMDD-Date in that format 9999-4 digit office code. 9999999-7 right p...

How to apply a SUM operation without grouping the results in SQL?

I have a table like this one: +----+---------+----------+ | id | group | value | +----+---------+----------+ | 1 | GROUP A | 0.641028 | | 2 | GROUP B | 0.946927 | | 3 | GROUP A | 0.811552 | | 4 | GROUP C | 0.216978 | | 5 | GROUP A | 0.650232 | +----+---------+----------+ If I perform the following query: SELECT `id`, S...

How to save unique alphanumeric content in MySQL?

for example 100-character long ...

why cant i set varchar to be 1000 in length.

if this matters, i also set it unique The max I've managed to set for varchar is 745 (it's set to unique also). ...

How to handle mysql's error on duplicate entry?

Sometimes when there's an entry about to be added to the database it failed because it's a duplicate entry, an error shows up. So, how to handle this error with the help of php? ...

i want to export table from SQL Server to mysql

Hi i want to migrate the tables from SQL Server to mysql, Can please refer some good tools or give some suggestion , how to start the migration , Also please tell me how to export the table in SQL Server. Thanks ...

Like and Where in the same MySQL query

I would like to use something like the following: SELECT city FROM cities WHERE city LIKE %D% AND country_id = '12' ...

How to remove or avoid inserting column headers when importing a separated value file into a database using PHP?

I have semicolon-separated .dat file and I want to read that file and store its contents into a database. Structure of .dat file: PARTYID;PARTYCODE;CONNECTION 256;319;234 879;435;135 SQL to import the .dat file: $sql_qry = "INSERT INTO DatTable (PARTYID,PARTYCODE,CONNECTIONID) VALUES ('$data[0]','$data[1]','$...

PHP & Mysql: optimize database

I have a database that has over 10,000,000 rows, querying it right now can take a few seconds just to find some basic information. This isn't preferable, I know that the best way to optimize is to minimize the number of rows which is possible but right now I don't have the time to do this. What's the easiest way to optimize a mysql dat...

How do I write this MySQL query to get the correct information? (Subquery, multiple subqueries)

Here is the query that I am working on: SELECT `unitid`, `name` FROM apartmentunits WHERE aptid = ( SELECT `aptid` FROM rentconditionsmap WHERE rentcondid = 1 AND condnum = 1 ) What I am having trouble figuring out is how to write this to add more rentcondition limiters to filter this list down more. SELECT `aptid` FROM rentcondi...

MYSQL query INNER JOIN two table

I have three tables CLASSES, CHILD_CLASSES, and STUDENTS. CLASSES looks like this (its self referencing): CLASS_ID | CLASS_PARENT | ------------------------- 1 | --- 2 | 1 3 | 2 CHILD_CLASSES looks like this: CC_ID | PARENT_CLASS_ID | CHILD_CLASS_ID ---------------------------------------- 1 ...

solr facets vs mysql relation schema

Hi, I am interested to find out what is the best/fastest (most efficient) way to query solr in a solr/mysql/app set up. I have a mysql DB that has one large main table and several smaller tables in a relational schema. I am also building an app which uses the hierarchy and builds menus based upon the data in the related tables. I start...

MySQL ODBC 32 vs 64 bit

I have a 32-bit application that must run on a Windows x64 server using a 64-bit version of MySQL. Should I use a 32-bit ODBC driver or a 64-bit ODBC driver? Or should I install a 32-bit version of MySQL too? ...

Why wont this sort in Solr work?

I need to sort on a date-field type, which name is "mod_date". It works like this in the browser adress-bar: http://localhost:8983/solr/select/?&q=bmw&sort=mod_date+desc But I am using a phpSolr client which sends an URL to Solr, and the url sent is this: fq=+category%3A%22Bilar%22+%2B+car_action%3AS%C3%A4ljes&version=1....

Can this this MySQL query (with subqueries) be optimized?

Is there any better way to make this query work? I'm looking for a more efficient solution, if there is one available. SELECT `unitid`, `name` FROM apartmentunits WHERE aptid IN ( SELECT `aptid` FROM rentconditionsmap WHERE rentcondid = 4 AND condnum = 1 ) AND aptid IN ( SELECT `aptid` FROM rentconditionsmap WHERE rentcondid = 2...

Mysql: money and floats

What float do I need to store such sums like these: $1,200,000, $1,000, and $14.56 ? ($ dosn't count; it will be removed) ...