Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Query Returns Empty Set


i have this query:
Code:

select p.url,s.tipo,pw.url as wrapper from secciones s
join plantillas p on s.plantilla=p.clave
join plantillas pw on p.wrapper=pw.clave
where s.clave=1

it works fine, the problem is that from time to time the second join condition won't match, because by design the field p.wrapper is optional, if that happens the query returns 'empty set' even if the where condition and the first join condition do match, is it possible to modify that query so it needs to match only the first join and the where clause to return the result set (i.e. make the second join optional)?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
DATABASES Returns Empty Set
I have mysql installed and many projects working off it. Now when i go into command line and type show databases; it says empty set? I have a database on my pc. why isnt it working threw command line????? Its saying empty set.

MySQL 5.0 EMPTY STRING Returns 'x'...
I am currently running mySQL 5.0 GA release and ODBC Driver 3.51 in Windows 2k3.

I am using mySQL with ASP .
For some reason while using the TEXT field type all EMPTRY strings returned via

dbRes.RecordSet("field_name")

are 'x'.

EMPTRY strings are returning with the character 'x'.

However changing the field_type to VARCHAR it returns ''; // which is correct.

So why is TEXT type returning 'x' when it is suppose to return '';

This is only occuring with mySQL 5.0 . I have tried this on mySQL 4.1 and it does not produce the same problem.

FIND_IN_SET Returns Empty Despite Valid Entries
i try to select all rows which have certain values of a SET, but whatever i do: the return is empty. the database is 4.1.11 and i use php to connect/query. locally the select works, but with mysql 4.0.25. it looks like this:

SELECT * FROM `table` WHERE FIND_IN_SET('val1,val3' , setField)>0;

i thought it has to do with character sets and encoding, but i found no solution to this problem. i know that there are rows which have val1 and val3 set. i even tried "val1,val2", being directly one after another, but still no result.

LOAD DATA INFILE - Returns Empty Datetime
I have a table with about 1 million rows. I want to use LOAD DATA INFILE because it's fast. Everything works, except: the datetime (last column of the row) is empty (0000-00-00 00:00:00).

This is the query I used:

HTML
LOAD DATA INFILE '/usr/tmpsql/db.sql' INTO TABLE track FIELDS TERMINATED BY ',' LINES TERMINATED BY '
'
This is the table structure:

HTML
CREATE TABLE `track` (
`id` int(11) NOT NULL auto_increment,
`nr` int(11) NOT NULL default Ɔ',
`ip` int(10) unsigned NOT NULL default Ɔ',
`ndate` datetime NOT NULL default ��-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `ip` (`ip`),
KEY `ndate` (`ndate`),
KEY `nr` (`nr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
the /usr/tmpsql/db.sql contains all INSERT commands like:


HTML
INSERT INTO `track` VALUES (4463027, 35225, 1154087817, ��-08-24 05:56:57');
INSERT INTO `track` VALUES (4463026, 47519, 1083028739, ��-08-24 05:56:57');


Query Returns Unexpected Users. Not Using Join.
Having a bit of a problem trying to get the correct results. Basically I have three tables I need to select from; user, platform and game.

I'm running the following query

select distinct
u.user_name,
u.user_avatar,
u.user_rating
from
user_game ug,
platform p,
user u
where
ug.game_id = 1
and p.platform_id = 1
and u.user_country = 1
Basically I want it to return users who own the game "1", have it on platform "1" and live in country "1".

Unfortunately does not return users who meet ALL WHERE criteria.

Any ideas where I am going wrong? I know an alternative is to use JOINS but I don't want the performance to be hit by doing that.

Use Where In Query So It Returns Rows That Has Less Than 10 Characters In The Word
I want to return rows that has less than 10 characters in the word that is used in the where clause sort of thing.

I can't really explain so I will give you an example, which is obviously wrong.

Quote:

mysql_query("select games from gaming where gamename < 10 characters");

My Query Returns Mysql Error 1267....why?
my query is not working... i am using 2 databases...

Running A 'Distinct' Query Returns Some Results TWICE !?
I've spent hours trying to find out why a perfectly simple query that uses the 'distinct' keyword such as:

Select distinct(field1)
From tablename;

works fine based on eg. field1, but when running it on eg. field2 in the very same table, it returns 2 results (yet, only on some words!). Pls see example of result below:

Eg of a 'faulty' result: .....

Error:Query Was Empty
What could be the cause of the above error
message to appear along with my error echo messages.

Empty Value In Multi Table Query
MySQL
SELECT p.`desc` ,
    IF(SUBSTRING(p.prodCode,1,3)='p1-',(SELECT p2.nPrice FROM tProducts p2 WHERE p2.prodCode=SUBSTRING(p.prodCode,4) LIMIT 1),0) as normalPrice,
    COUNT(DISTINCT pic.ordering) as pic_count
FROM
    tProducts p
    JOIN prod_subCats psc ON p.productID=psc.relProdId
    LEFT JOIN taxCodes tax ON p.taxCode=tax.taxCode
    LEFT JOIN suppliers s ON p.supplierID=s.supplierID
    LEFT JOIN pictures pic ON p.productID=pic.relProdId
    LEFT JOIN freeProducts fp ON p.productID = fp.productID
    LEFT JOIN tProducts freeProd ON fp.freeProductID=freeProd.productID
    LEFT JOIN pictures freePic ON freeProd.productID=freePic.relProdId
    LEFT JOIN prodReviews review ON p.productID=review.productID AND review.status=1
   
    WHERE p.stocklevel>-3 AND psc.relSubCatId=7235
    GROUP BY p.productID
LIMIT 1

The value p.`desc` comes up blank (not null, just blank) in this query, though I know this data is there.
If I remove either of the other 2 fields for the query, the correct data for field p.`desc` is returned.
This kind of thing would normally happen when you specify fields with the same name from different tables, either explicitly, or using *. But as far as I can tell, all my fields & tables are correctly aliased etc
To further confuse matters, this problem occurs on my (windows) development server running v4.1.1, but not the (linux) production machine running v 4.1.2
I'm stumped.

Empty/NULL Query Or State
When running SHOW FULL PROCESSLIST (or mytop) we're seeing huge numbers of empty queries.

Example:
http://pastie.caboo.se/pastes/201976

When checking out the Info column, both it and the Query/State fields are NULL.
These huge spikes of empty queries also correspond with a major slowdown of our server so it leads me to assume that the empty queries have something to do with our server speed issues.
Any ideas why we're seeing so many empty queries and what we might can do to fix it?
We're running MySQL 5.0.51b.

Error 1605 : Query Was Empty Please Reply
when I am restoring the database on local machine.

using command :

mysql -u username DatabaseName < pathForResotoreFile -p password.

I am getting error -> "Error 1605 : Query was empty" on line 7 in back up file.

When i checked the backup file at line 7 there are comments.

Couldn't Execute '/*!40100 SET @@SQL_MODE='' */': Query Was Empty (1065)
I upgraded to MySQL 5.0, but the remote server still runs 3.23. Before I upgraded I was able to, in a local DOS-prompt, execute a mysqldump and get the database from the server to a file on my computer. Now, when I execute the same query, the remote server does not understand my command.

This is what I execute on my local computer (simplified):
C:foldermysqldump --add-locks --add-drop-table -h xx.xx.xxx.xx -u username -p database > "C:folderdb_downloaded.sql"

This used to work, but after I upgraded I get the error message:
Couldn't execute '/*!40100 SET @@SQL_MODE='' */': Query was empty (1065)

What's Wrong With My Query To Filter Double Entries And Skip Empty Rows?
I am trying to get filter a database table.
- skip empty rows (i.e. ecardNameSender is empty)
- filter double entries

$sql = "SELECT COUNT(*) as total FROM tblEcards WHERE ecardNameSender != '' GROUP BY ecardEmailFriend";
$result = @mysql_query($sql, $connDB);
$row = mysql_fetch_assoc($result);
$totalPics = $row['total'];
echo $totalPics;
What's wrong with my query?

LAST_INSERT_ID() Returns Zero
I'm executing a query like this:

MySQL
INSERT INTO `Members` (`UID`, `Username`, `Password`) VALUES(NULL, 'username', ?')

Immediately after, I'm trying to use mysqli_insert_id() from my PHP script. However, I keep getting a zero back from the function. I have used MySQL GUI Tools to verify that the row was definitely added, and it has a unique row number (40001 in my tests). I've tried recreating these queries manually from the GUI Tools to make sure it wasn't my script, and they encounter the same error. Even:

MySQL
SELECT LAST_INSERT_ID()
returns zero!

-----------------------

Here's how my table looks:

MySQL
CREATE TABLE `Database`.`Members` (
                            `UID` MEDIUMINT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
                            `Username` VARCHAR( 32 ) NOT NULL ,
                            `Password` BINARY( 32 ) NOT NULL ,
                            UNIQUE (
                            `Username`
                            )
                            ) ENGINE = INNODB

Server version: MySQL 5.0.32-Debian_7etch1-log via TCP/IP
GUI Tools Client Version: MySQL Client Version 5.1.11

LEFT() Returns Nothing
How comes this always return nothing even though i have data in the name field

SELECT Left(joueurs.name,1) AS newName FROM joueurs

LIMIT Returns
i have a table with 64K+ rows, a query like this:

select * from mails order by clave desc limit 1;

effectively returns the last record (key:64103) but if i try a query with a hight number as offset like this:

SELECT * FROM mails LIMIT 64000 , 30;

returns nothing, i've tried in the console and from phpmyadmin with the same result, a "select count(*) from mails;" query returns 64096.

does anybody knows what could be wrong? i've noticed mysql stops returning rows after ~21998 records

Limit Returns
Is there a way to do something in the WHERE clause that will only pull back entries in the DB from the last 7 days?
Could this work: WHERE field < NOW()-7 or something like that. Or could I do a php $date = date()-7 or seomthing like that?

How To Get 5 Random Returns From Mysql?
I have a table that stores username and image_id. Like -

user_name | image_id

user_1 | image_1
user_2 | image_2
user_3 | image_33
user_2 | image_56 etc.

I need to get 5 random image_ids, each from a different user. I was considering using rand(), but google told me that this will slow down the sql server, bigger the database.

PHP

SELECT DISTINCT user_name, image_id FROM tablename ORDER BY RAND() LIMIT 5

SQL Select Statement Returns Nothing?
When I view this page, nothing appears in the browser

PHP

while($row = mysql_fetch_array($result)){$Identifier = $row['ID'];$random_thumb_query = mysql_query("    SELECT userid, filename    FROM photo_photoplog_fileuploads    WHERE moderate = 0    AND userid = '$Identifier'    ORDER BY dateline DESC    LIMIT 1") or die(mysql_error());$random_thumb_row = mysql_fetch_array($random_thumb_query);echo $random_thumb_row;$random_thumb_nail = '<img src="/photoplog/images/'.$random_thumb_row['userid'].'/small/'.$random_thumb_row['filename'].'" alt="" border="0" />'


http://miamiasp.com/providers.php
u:luke
x: urtnowski
is the $Identifier variable ok?

Getting The Row Where Forumula Returns Smallest Value
i am trying to select one particular row of data from a table which has the least difference between two other columns from another table.
i have been looking at the documentation and keep trying. this is the closest i could get but it is still not right.

select * from photographs group by ( select min(p.rate-p.comments) from photorates as p )
this could sometimes return me multiple rows and if i were to change it to:

select * from photographs group by ( select max(p.rate-p.comments) from photorates as p )
having max instead of min, i get the min and max rows of data. i suppose i should only get one row of data since i need either the least or most difference from the math.

LIMIT 5 Only Returns 2 When Using GROUP_CONCAT
I'm trying to limit my results in the following query. When I make this query without the GROUP_CONCAT lines, I get the number of results I specified in LIMIT, when I put those lines back in, I get less than the number of results I specify with LIMIT....

Select * Returns No Data
I have a problem where if I issue a select * from against a database it returns no data,

but if I select column from it returns the data.

Why would the * not be working as a wildcard?

Troubleshooting Carriage Returns In Csv
I am exporting data from filemakerpro in a csv file and uploading it via cocoamysql/phpmyadmin, from which it is viewable online through dynamic pages. Carriage returns in Filemaker are translating through as small boxes (firefox), small boxes with X's inside (safari); in the csv file they are tranlating as either spaces or nothing (just jams the words together where there should be a return).

Any ideas on how to eliminate this problem? or a direction to look in?

Found_rows() Everytime Returns 1
I use this query
SELECT SQL_CALC_FOUND_ROWS * FROM prods LIMIT 100,10;

I'd like to know how many rows this query returns without limit, but
using this
select FOUND_ROWS();
the result is everytime 1

You know why?
No other query are processed before the found_rows().

Import CSV With Carriage Returns
How do I use the import function in the phpMyAdmin to import a CSV file that contains carriage returns. Or is there a better format to import data with carriage returns.

CONCAT () Returns BLOB
MySQL ver. 3.23.49

SELECT tblHrsClass.classid , CONCAT( tblHrsClass.classTtl ,' ', tblHrsClass.classDate ) class_ttl FROM tblHrsStudent LEFT JOIN tblHrsClass ON tblHrsStudent . classid =tblHrsClass.classid GROUP BY tblHrsClass . classid HAVING COUNT(tblHrsStudent . classid )<19

The query above is broke. I'm using it to build a list box.

I can run the query without the CONCAT function and pulls the expected data.

When I add CONCAT( tblHrsClass.classTtl ,' ', tblHrsClass.classDate ) class_ttl,

class_ttl is returned as a BLOB of a certain size.

Result Set Returns A Null Value
How do work on a situation when result set returns no records ???when result set returns a value null how do you send it to some page

I have tried </jsp:forward aaa.jsp>  but it does not seem to work .Can any body suggest a remedy to it.

Line Returns In Fields
In many of my text fields in my table, there appears to be a line return before the text begins (I can see the line return when the table is displayed in myphpAdmin). But when I EDIT the line, there is no line return... the text is at the TOP of the box.

However, if I delete the line, and re-type it, the line return goes away. I tried the TRIM command and it doesn't work. Its causing a problem because I can't compare these columns to other tables that don't have the line return.

Remove Carriage Returns
I have a text file with email addresses that I'm importing into a table and there are carriage returns after each email address which is causing problems. Is it possible to remove the carriage returns using a query?

No Carriage Returns In An CFM Script
I have a simple publishing script written in Cold Fusion. When I insert text via the admin web page form the script doesn't take my carriage returns into the database. I have to write html-code <p> wich is very frustrating. Does anyone have a clue how to fix this problem?

I've tried to get a solution via Cold Fusion sources but without success. I don't know if the problem is in the CF scripting or the MySQL database.

I have My SQL 3.23.58 and Cold Fusion 6 running on a Linux Red Hat with Apache.

Clause Returns No Results
i have a product table and i execute a simple query but it doesnt seem to give me any results

Select * from product where ProductName = 'Age of Empires III';

the above query doesnt work but this 1 does
Select * from product where ProductName LIKE 'Age%';

Group By Returns Invalid Dates
Hi i have one table:

ID, User, Score, Date
1, mac, 1234, 2007-12-09 09:01:07
2,kurca, 3232, 2007-12-05 09:43:57
3, mac, 999999, 2007-11-07 09:44:14

I wan to create a high score list which will represent the best scores but not repeating anyone for example:
1, mac, 999999, 2007-11-07 09:44:14
2,kurca, 3232, 2007-12-05 09:43:57


Now i use:
SELECT ID, User,MAX(Score) as maxScore,Date
FROM `table`
GROUP BY User
ORDER BY maxScore DESC

with this query the score is right but the date is invalid example:
1, mac, 999999,2007-12-09 09:01:07
2,kurca, 3232, 2007-12-05 09:43:57

REGEXP That Returns Index Of Match?
Is there any way to use a REGEXP but have it tell me where in the string it occurred?  Or is there a way to do what I want without REGEXP?

I have a field (lyrics of songs) that, in the case of songs sung in Japanese, contains Japanese lyrics followed by the English equivalent.  I want to be able to find the spot where the English starts and either return just the Japanese or return just the English.  There may be sets of square brackets with English characters (guitar chords) inline in either the Japanese or English, so I also have to watch out for that.

To help you understand what I mean, let's hypothetically say that there is a regexp "function" that returns the index to the first occurrence of a match (which MySQL's REGEXP operator does not appear to do).  If that were the case, I would do something like this:

SELECT SUBSTRING(Lyrics,0,REGEXP(Lyrics,'^([[^]]])?[a-zA-Z]')) AS Japanese FROM song...
SELECT SUBSTRING(Lyrics,REGEXP(Lyrics,'^([[^]]])?[a-zA-Z]')) AS English FROM song...

Int(3) Returns 5 Digit Number On Select
If I have a field with a data type of int with a size of 3, why would I get a 5-digit number when I query it? ...

mysql> desc prod_cat;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| rel_id      | int(3)       | NO   | PRI | NULL    | auto_increment |
| prod_id     | varchar(255) | NO   | MUL | NULL    |                |
| category    | varchar(255) | NO   |     | NULL    |                |
| subcategory | varchar(255) | NO   |     | NULL    |                |
+-------------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)

mysql> select * from prod_cat where prod_id = 'DATAPROZ';
+--------+----------+--------------------+-------------+
| rel_id | prod_id  | category           | subcategory |
+--------+----------+--------------------+-------------+
|  20955 | DATAPROZ | Money & Employment | Jobs        |
+--------+----------+--------------------+-------------+
1 row in set (0.01 sec)

MySQLCC Returns 1000 Row Limit
When I double click on a table in mysqlcc only the first 1000 rows are returned. I know there is a way to change this Limit as I did it over a year ago on another machine- and forgot to write down how!

I need to change this limit somehw- and somewhere so I get back all the rows- or a large number > 1000. If anybody has done this please refresh my memory-

Entering Data Into Db With Hard Returns
I have a html textarea where user submit text and it gets stored in a db. For example:

This is a test. Here is my list...
one
two
three

See, the text has hard returns in it, but when i output it back on the page with php, it all goes into a continuous line.

How can i have the hard returns in the output. Like I have the '' included.

Stored Procedure Returns Same Records...
My stored procedure returns same records, the values are from the first record. Code:

USER() Function Returns Hostname
Can anyone tell me how to return the username of the currently logged in user without the hostname included.

e.g. at the moment:-
SELECT USER() AS username
->
root@localhost

but I really want
SELECT (USER) AS username
->
root

Is there a function to do this, or is there a string search (and chop up) set of functions I'd need to use?

JOIN Returns Duplicate Data
I am querying from 2 tables asuch:

t1 = property listings
t2 = property photos

SELECT t1.id, t1.area, t1.address, t1.price, t1.bedrooms, t1.bathrooms, t2.fileid
FROM listings AS t1, album AS t2 WHERE t1.id = t2.propid AND status LIKE 'for sale';

I am getting duplicate records when multiple photos are present, eg:

+-----+----------+-------------------------------------+
| id | price | fileid |
+---+----------+-------------------------------------+
| 1 | 899000 | 4490082059794440261166380 |
| 2 | 995000 | 1072603818590874471784367 |
| 3 | 630000 | 1192880275852882142198181 |
| 3 | 630000 | 7498054893972972542204555 |
+-----+----------+-------------------------------------+

Select Distinct Returns Duplicates
I only want to return one row for driver_guide 46 but "select distinct driver_guide,driver_make..." returns both records:
CODEdriver_guide| driver_make
46          |Jaguar
46          |Ford

Importing Db Table Returns 404 Error
I'm using phpMyAdmin and looking for a work around to change fields values or import new tables but I'm running into what I think is a permission problem.
 
 I go to import the db.sql them prompted with the alert "this page contains secure and nonsecure items" resulting in a 404 type error "page cant be displayed"

 Anyways here is the problem in a nutshell I think is the solution but there might be more. Still learning.

Remove Hard Returns In DB Field
I have a simple PHP page that is adding data to a mysql database (longtext as the type).
Now as it stands - when a user presses "enter" then add more text, the results (when displayed) have a hard line return. How do I modify this behavior? I just want it to be captured exactly as the user enters it....
IE - press enter and the text starts on hte next line, and hit it twice, and it shows up 2 lines below with a space in between.

ERROR 1242 (21000): Subquery Returns More Than 1 Row
I am having a trouble with concat_ws.

Consider the following example (table type is innoDB):

How To Implment The Function With TABLE Type Returns?
I try to transfer a function with table type returns from Sql Server to mysql.But I fail.
I want to know if mysql supports the function with table type returns.or give me a example. Code:

Select All Statement Returns Unreadable Data
I am connecting to mysql via ssh and am trying to view all my tables to see if my data was inserted correctly.I have over 100 fields in one table.If anyone has any suggestions on how I can get my data returned ledgably.

Auto Script Returns Error Accessing Database
I have a shopping cart with an automatic installation script. Add a new
database without tables, configure the script with the table's
user/password, and it's supposed to set up all the tables in the database.

Yet each time I call the setup program, I get this error:

DataBase Error, mySQL Error Reason :
Access denied for user: 'username@domain.com' (Using password: YES) at
/home/webadmin/[omitted]/cgi-bin/[omitted].pm line 109

The password appearing in the script is definitely not "YES" and I have
checked to ensure that the script contains the correct user and password
for the database.'

Empty Set
I'm learning how to use MySQL at the moent and according to my book I needed to load data into the table president I created from a file, so I gave the following command:

LOAD DATA LOCAL INFILE "C:/samp_db/insert_president.sql" INTO TABLE president;

Reply:

Query OK, 42 rows affected, 294 warnings (0.01 sec)
Records: 42 Deleted: 0 Skipped: 0 Warnings: 294

When I now try to search for data I get the following result, this is the way I'm trying to do it.

SELECT last_name, first_name FROM president
WHERE last_name="ROOSEVELT";

Reply:

Empty set (0.00 sec)

This is a part of the file:

DELETE FROM president;
INSERT INTO president VALUES ('Washington','George',NULL,'Wakefield','VA','1732-02-22','1799-12-14');
INSERT INTO president VALUES ('Adams','John',NULL,'Braintree','MA','1735-10-30','1826-07-04');
etc.

Could any one see what I am doing wrong here?

Empty Set
how do i validate if a 'mysql_query' statement returns an 'empty set'?

this not works.........

$result=mysql_query($query,$con);
if(!$result)
{
echo "Error";
}


Copyright © 2005-08 www.BigResource.com, All rights reserved