mysql-query

mysql conditional insert - if not exists insert - multi value insert

From my previous question this was the solution I am accepting: INSERT IGNORE INTO table_name SET name = 'phill', value = 'person', id = 12345; But I also wanted to know if I could be multiple values like this INSERT IGNORE INTO table_name SET (name = 'phill', value = 'person', id = 12345), (name = 'bob', value = 'person'...

How can I dump a MySQL database from mysql c library.

I want to archive my database of mysql. Kindly give me some guide lines how I can make it possible, I am using mysql c library for insertion and selection etc. I dont know how to use dump command. ...

Mysql - How to update a column using another column's value plus some strings

Hi all, I have a table with the following column & value: ColA = "8765" ColB = "2137" I would like to update ColB in the same table to the following value: ColC = "[8765][2137]" How can I do it using phpmyadmin (meaning just sql sytnax)? ...

SQL query to show most ordered product

I have this table structure Product product_id (PK) name Order_Detail order_detail_id product_id quantity Example data Product : 1 product1 2 product2 3 product3 4 product4 5 product5 Order_Detail : 1 3 2 2 3 1 3 3 1 4 2 1 5 2 1 6 1 1 7 4 1 8 5 1 9 1 1 10 2 1 11 3 1 Please help me to get top 3 ordered product based on how m...

Select Query with MAX

Hey Guys, i've got a big Problem and i was trying the whole day and did not find any Solution. Hope you can help me? I have two tables: The first one named "orders": orders_id | orders_date | ..... 1 xxxxxxxxxx 2 xxxxxxxxxx 3 xxxxxxxxxx The second is "orders_history": orders_id | order_status_id | dat...

SELECT Statement Performance using * versus a List of Field Names

Possible Duplicate: Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc. In some code I'm reading, all SELECT statements are using a list of field names where all fields in the table are being selected. For example, with a table called Book and fields Author, PublishDate, Pages and Price, the select statem...

cities and distance by latitute-longitude

I have a table with: city latitude longitude And I need a sql query to know all cities are 100 miles from new york. Could anyone help me before I go crazy ? ...

php and mysql function not working

Im sorry if this post is long winded I have 2 php functions that that gets data from the database, the first one works fine but the second one doesnt seem to work and I cant find the cours. I hope somebody can find out, I have include the code for both functions and how I used them function data_to_maani_xml() { $i=0; $xml="<ch...

PHP+MySQL join statement arrange multiple values as row in mysql_fetch array

hi, I am using a MySQL INNER JOIN statement which returns various results for one distinct record in the main table from the joins, similar to http://stackoverflow.com/questions/1038653/how-to-join-multiple-joins-yet-return-distinct-values My query is SELECT cl.*, dep.dept_name FROM epapers.clientelle cl INNER JOIN epapers.dept_s...

Can anyone explain to me what this query does?

I need the riposte in layman's language. SELECT t1.* , IF(isBranch='true','',IF(pointsweightage IS NULL,'Not Set',pointsweightage)) AS w , t2.id AS wid FROM `skills_hierarchy` t1 LEFT JOIN weightage t2 ON t1.pointsweightage=t2.weightage WHERE isBranch='false' AND t1.deptid=$deptid AND t2.deptid=$d...

SQL-query to find articles with at least one of the listed tags

I have 3 tables: articles, tags and article_tag (the one which connects them). I'd like to find all articles that have some (or all) of the tags listed in the query and order them by the number of matched tags. Is it possible? Example in english: Query: Find me all articles that have at least one of these tags "jazz, bass guitar, soul...

Mysql optimization, muliple select to single select

hi, I have table where I need to select MAX(SUM(total)) of a periods total. SELECT SUM(P.amount) as total FROM bank P WHERE P.ReceivedDate >= '2008-07-28' AND P.ReceivedDate <= '2008-08-31'; SELECT SUM(P.amount) as total FROM bank P WHERE P.ReceivedDate >= '2008-09-01' AND P.ReceivedDate <= '2008-09-28'; SELECT SUM(P.amount) as total...

update all the fields in table which have empty values (MYSQL)

Is there any way to update all the records in a table if there is atleast one filed which has empty value? Thanks. ...

SQL SEARCHING relational database

given a users qualification id's how would you find the jobs they can do using SQL? 1) for example a user with only qualification 1 could only do job3 and not 1 and 4 because you need more than one qualification. 2) a user with qualifications 1 and 2 could do jobs 1 and 3 but not 4 JOBDETAILS TABLE JobID ,QualificationID 1, 1 1, 2 ...

Mysql Count(*) as Total WHERE Total ??

SELECT Id, QId, UName, Ans, Date, COUNT(*) * 10 as Total FROM question WHERE COUNT(*) DESC GROUP BY UName doesn't work :( ...

Mysql - Valid Unique E-mail

I want to get the total number of all valid e-mail address in a database, but I also want the total to be unique e-mail addresses. Is this possible with mysql alone? ...

mySQL -problem grouping and returning correct values using GROUP BY / HAVING

I have a crossReference table (crossref_room_subject) with conference room, meeting subject and timeSlot IDs. There are multiple entries per timeSlot. The subjectCode table includes a subjectCodeCategory ID also (only one category per subject but multiple subjects per category). For one query that is working, the user is entering mult...

MYSQL top N rows from multiple table join

Like, there is top keyword in sql server 2005, how to select top 1 row in mysql if i have join on multiple table & want to retrieve extreme of each ID/column. Limit restricts the no. of row returns so it can't solve my problem. ...

User built navigation help

Hello, I am currently trying to build a navigation that is semi built by the user, basically the user has a primary navigation in which if they click on a category name a block is created on the page for that category. If they click the same link again the block is removed from the page, the website is set up to remember which blocks the...

Mysql is it possible to do the following?

Hello, I have a mysql query, that does the following, SELECT * FROM categoryTable LEFT JOIN userMenuTable ON userMenuTable.categoryId = categoryTable.categoryId this returns only results that match this condition ON userMenuTable.categoryId = categoryTable.categoryId I was hoping it would be possible to pull all the results and ...