mysql

How to find out the location of currently used MySQL configuration file in linux

How do I know which configuration file is used by MySQL currently? Is there any command or something to find it out? ...

which is better single query or multiple query??

I do have 8 tables. when a query fires from search page data from all these 8 tables is pulled out and displayed on the result page. What I want to know is which is the best optimized query method for this process?? what I do now is : $result = mysql_query("SELECT * FROM TG_dat,TG_dat1,TG_dat2,TG_dat3 WHERE TG_dat.web = TG_dat1.web A...

MySQL trigger issue

I got this trigger, I want to evaluate the mobile phone and insert into another table if the regexp returns a value. I've tried with this but not success. delimiter // create trigger companyA_phones after insert on customer for each row begin set @phone = (select new.phone from customer where new.phone regexp '^0416'); if (@p...

Get the rows, where day is equal to some value

I have a field with type= date in MySQL DB. It store dates in YY-m-d format. How can I write a query which will get the rows where day is equal to some value, for example 1? I need to get only first days of months (2009-11-01, 2009-12-01, 2010-01-01...) Thanks ...

mysql indexes to set for a query

What indexes i have to set for a query like this? thanks SELECT distinct event_dates.* FROM `event_dates` INNER JOIN `events` ON `events`.id = `event_dates`.event_id INNER JOIN `cores` ON `cores`.resource_id = `events`.id AND cores.resource_type = 'Event' INNER JOIN `cores_kinds` ON `cores_kinds`.core_id = `cores`.id INNER JOIN `kin...

How to work with mysql in C# ?

my visual studio 2008 don't know "MySql.Data.MySqlClient" and says: "The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)" what should I do now? ...

[Mysql] Using index on join

Using EXPLAIN for the query below shows SELECT cha.cid AS cid, cha.data AS dl FROM cha, c_users WHERE uid = 808 AND cha.cid = c_users.cid; it does a full scan on cha table uses the multi column index(cid,uid) from c_users. Why doesn't it not use the primary key index from cha and rather does a full table scan. Is there a b...

Find value between two data range in MySql

I have a table with three fields id,minvalue and maxvalue.These fields carries multiple values like... id Minvalue maxvalue 1 100 200 2 201 300 3 301 400 ...and so on. If I supply 250 as input, how can I retrieve its corresponding id using mysql query? Thanks ...

Mysql MATCH AGAINST - IN BOOLEAN MODE problem

I need to find the following string: 'c++' My sql query look like this: SELECT * FROM shop_product WHERE MATCH(shop_product.name, shop_product.product_model, shop_product.keywords, shop_product.part_number, shop_product.upc, shop_product.brand_name) AGAINST ('c++' IN BOOLEAN MODE)) GROUP BY `product_id` LIMIT 0, 25 This script ...

mysql selecting data poblem

I have two tables, products and product_tags. products table; product_id int name varchar description text price decimal(12,2) status enum sale int hit int date_add datatime date_update datetime product_tags table; tag_id int product_id int tag varchar where the product_tags table has a one to many relation with products, for exa...

how to delete duplicate rows from a table in mysql

I need to delete duplicate record from table in mysql. So i have a table name "employee" fields are empid, empname, empssn for getting duplicate record i have written a query SELECT COUNT(empssn), empssn FROM employee GROUP BY empssn HAVING COUNT(empssn)>1 Now i want to delete duplicate records. for that i have wr...

Data duplication using mysql query

Dear all, I wanted a guidance for one problem . Suppose i have one table alphabets (alpha, id). In column alpha having value a-z and in column id all values are 1. a 1 b 1 . . . . z 1 Now i want a database query to insert data like a-z but with id=2 . Can anybody help me out . ...

how to use quote in mysql syntax ?

I try this in PHPMyadmin: Update wp_1_posts SET post_content='<strong>Hello </strong> <a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt; you think you're good at sql.\n then answer\n' WHERE post_ti<tle = 'stupid example' and it says bad syntax. Why ? ...

MySQLi: SELECT priority using OR

I have a photos table in the database that uses a status column to detect if the photo was validated or not... so if a photo has a status = 0 then its not validated, but if status = 1 then the photo was validated. I want to add status = 2 for selecting the photo as the 'main photo' so I can use SELECT photo WHERE status = 2 but if t...

MYSQL query help (EAV Table)

I have the following query to retrieve customers who answer YES to a particular question "OR" NO to another question. SELECT customers.id FROM customers, responses WHERE ( ( responses.question_id = 5 AND responses.value_enum = 'YES' ) OR ( responses.question_id = 9 AND responses.value_enum = 'NO' ) ) GROUP BY customers.id Which works ...

Having troubles configuring PHP to work with mySQL

I'm venturing out of the world of .NET and into the world of open-source. However, I've hit a few roadblocks while trying to get my development environment set up. And I'm kind of stuck on the most recent one. I have installed: Apache 2.2, php 5.3.2, and mySQL 5.1.48 everything is working pretty much; apache is serving up PHP pages, ...

Getting sum() on a different distinct row MySQL

Hello, I was looking on different questions on this issue, but couldn't find an answer for my problem. This is my query: SELECT SUM( lead_value ) AS lead_value_sum, count( DISTINCT phone ) AS SUM, referer FROM leads t1 INNER JOIN leads_people_details t2 ON t1.lead_id = t2.lead_id INNER JOIN user_to_leads t3 ON t1.lead_id = t3.lead_id ...

Upgraded python and can't get mysqldb to work

Running OSX 10.6.3 Just updated python to Python 2.6.5 (r265:79359 rebuilt and reinstalled mysqldb (MySQL-python-1.2.3) rebuilt and reinstalled django (<-- should be unrelated. problem seems to be with mysqldb) I'm getting the following error. File "<stdin>", line 1, in <module> File "build/bdist.macosx-10.3-fat/egg/MySQLdb/__init_...

propercase mysql udf

I am trying to write a custom propercase user defined function for mysql so i took the str_ucwords function from http://www.mysqludf.org/index.php as an example to build my own. my_bool str_ucwords_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { /* make sure user has provided exactly one string argument */ if (args->arg_...

Can you optimize this SQL query for me?

I'm running this query in 2 mysql_query calls. I would like to do the most performant thing and run it in one query. Can anyone optimize this for me: if(mysql_num_rows(eq("select * from player_data where uid = $uid")) == 0 ) eq("update player_data set uid = $uid, ...