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




Order By Not Working Correctly, Query Problem?


I am using the following query to get a list of anime names and related info from my mysql db. As anime are sometimes known by several names (the actual japanese kantakana/kanji, the romanji translation and the english word). So the info_anime table has all the info about the anime and the info_animename just has the relevent animeid and the name.

The query below is ment to check all the names in info_animename and join them to info_anime.

SQL
SELECT n.*, a.* FROM info_animename AS n, info_anime AS a
WHERE
 a.animeid = n.animeid
ORDER BY ".$_GET[orderby]." ".$_GET[order]."

Now all the names are displayed properly with the various info but if you look here:

Live Anime - Anime List

You will see that the names are not in alphabetical order, for the most part they are just anime with several names are not working correctly if you look at the bottom of the page you will see:

Yakusoku no Basho Kumo no Mukou followed by
Beyond The Clouds, The Promised Place

Which are the same anime under different names.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
MySQL Dump Not Working Correctly
I have a table in MySQL. nightly, the table is dumped (structure and data) and imported into a different database. it has been working fine like that for 3+ yrs. I recently added a new column. i populated it w/ values. the rest of the dump goes correctly, but no matter what, it will not dump this column's values.
in the dump it will just show empty braces.

The columns structure is set to DEFAULT NULL VARCHAR(50). I know im probably missing something, im not a database expert by any stretch.

ORDER BY Not Working With DISTINCT
I'm having trouble with an apparent conflict between ORDER BY and DISTINCT. I start with the following query:

SELECT route_id FROM point_table ORDER BY SQRT(POW((42.40 - y_coord), 2) + POW((-71.14 - x_coord), 2)) LIMIT 10

That query returns:

87, 87, 87, 87, 87, 87, 54, 9, 87, 128

What this is showing is the route_id's for the 10 closest points to the lat/long point (42.40, -71.14). That data is absolutely correct: the closest six points belong to route 87, the next point belongs to 54, etc.

What I really want is a list of the 10 closest route_id's, so I add a DISTINCT clause to my query:

SELECT DISTINCT route_id FROM point_table ORDER BY SQRT(POW((42.40 - y_coord), 2) + POW((-71.14 - x_coord), 2)) LIMIT 10

However, this returns:

130, 87, 63, 128, 71, 64, 65, 70, 69, 132

I expected to get 87, 54, 9, 128, etc. However, adding the DISTINCT clause appears to be altering the ORDER BY behavior from the original query.

A comment made by Mark on August 21 2006, describes a similar problem, but I can't make any sense out of what he's doing:

http://dev.mysql.com/doc/refman/5.1/en/distinct-optimization.html

Can anyone help me to understand what's going on?

Order And Limit Not Working As Expected
I have a fairly simple table that stores a huge amount of data. I am displaying this data through perl on a web page, and due to the number of records, I am using the LIMIT clause to page the data. However, when I attempt to use an ORDER clause along with the LIMIT clause, it is not working as expected.

SELECT * FROM quarantine ORDER BY to_address, quarantine_date LIMIT 0, 25

The above query returns the first 25 rows in the order specified by the query. What I need is the entire table sorted, then the first 25 rows returned. How would I accomplish that?

Query Not Working In 5.0 That Worked In 4.0
I've created a development site for my website that uses mysql 5.0.18 and my live site uses 4.0.16. I have a query I can run without problems on the live site but is giving me errors on the development site and I was hoping someone might know what the problem is. It must be some change to the syntax standard I suppose. Thanks for your help!!!

1054 - Unknown column 'p.products_id' in 'on clause'

select count(p.products_id) as total from products_to_products as pp, products p, products_description pd, manufacturers m left join specials s on p.products_id = s.products_id where pp.products_id=�' and p.products_id = pp.related_products_id and pd.products_id=p.products_id and p.products_status = Ƈ' and pd.language_id = Ƈ' and m.manufacturers_id = p.manufacturers_id

ANDs In Query Not Working
I am working with this query:

SELECT * FROM reviews WHERE gID = 'nothing' OR gID = '825' OR gID = '864' OR gID = '632' OR gID = '880' OR gID = '839' OR gID = '534' OR gID = '680' OR gID = 'x' AND type = 'online' AND status = '1' ORDER BY RAND() LIMIT 0, 10

With everything going on here, the most important is that only rows with status=1 are selected. However, I am getting some rows with status=0 in my results. Is there something wrong with the ANDs in my query?

Update Query Not Working: SQL Error
i'm trying to do an update such as ...

Simple Mysql Query Not Working
I have a simple table set up listing stockists and there details, included in this table I have a name column and a website column.

I wish to select the name and the website of the stockists only if a website has been entered into the website column.

Here is the query I have tried to use
Quote:

SELECT name, website FROM stockists WHERE website IS NOT NULL ORDER BY name ASC

This query is returning stockists with no website as well as the ones with websites and I don’t know why!



Query Of Gmdate Not Working... Is My Syntax Correct?
$query="SELECT distinct(id),subject,view, postdate FROM threads where gmdate(Y-m-d H:i:s, postdate + 3600) >= date_sub('".$current_date."', interval 7 day) order by view desc limit 0 , 5 ";

I tried to get my postdate to compare with the current date in order to display the most view topic in last 7 days in my page...

however, the above coding is not working...

Query To Display The Rows As Colums Is Not Working!!
I want a select query to get two columns. but i need to get these columns one below the other that is consider that i have a table student in that i have 2 columns name mark.
Now i want the result as

Name Raj Rina Tina
Marks 80 90 70

I tried the --vertical option of mysql and G option in the query.

for example when i tried

select *from studentsG

it displayed

*********** 1. row ***********
name: Raj
marks : 80
********** 2. row ************
name: Rina
marks : 90
********** 3. row ************
name: Tina
marks : 70

but i want to display

Name Raj Rina Tina
Marks 80 90 70

Query Cache Not Working: MySQL 5 / Windows XP
I just installed MySQL 5, and its running great except that the query cache is not working, despite the configuration excerpt from my "my.ini"
below:

query_cache_size=5M
query_cache_limit=2M
query_cache_min_res_unit=4096k
query_cache_type=1

From the MySQL command line, if I enter: SHOW VARIABLES LIKE
'have_query_cache';

I get:
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_query_cache | YES |
+------------------+-------+

Also, doing a: SHOW STATUS LIKE 'Qcache%'; gives me:

+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| Qcache_free_blocks | 1 |
| Qcache_free_memory | 5234168 |
| Qcache_hits | 0 |
| Qcache_inserts | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 450 |
| Qcache_queries_in_cache | 0 |
| Qcache_total_blocks | 1 |
+-------------------------+---------+


I figure the "Qcache_free_blocks" and "Qcache_total_blocks" values of 1
are creating the problem; it's basically telling me that there are no
(okay, 1) free blocks to put my query. However, these values never
change.

The query cache is not vital to me, but it does improve performance, and
I'd like to get it going....

Not Summing Correctly
This query will is not showing sums of the individual line items. The tabl shows stats for each player each day, yet even though the intent of the query is to show a sum of each player it is not.
Can anyone tell me what I'm doing wrong?

select distinct `ssfhl4_ssfhl`.`tblplayers`.`Player` AS `Player`,`ssfhl4_ssfhl`.`tblcummstats`.`Position` AS `Position`,`ssfhl4_ssfhl`.`tblcummstats`.`NHLTeam` AS `NHLTeam`,`ssfhl4_ssfhl`.`tblcummstats`.`Status` AS `Status`,`ssfhl4_ssfhl`.`tblplayers`.`Salary` AS `Salary`,`ssfhl4_ssfhl`.`tblcummstats`.`WeekNo` AS `WeekNo`,`ssfhl4_ssfhl`.`tblcummstats`.`FanTeam` AS `FanTeam`,`ssfhl4_ssfhl`.`tblcummstats`.`DateStamp` AS `DateStamp`,`ssfhl4_ssfhl`.`tblcummstats`.`PlayerID` AS `PlayerID`,`ssfhl4_ssfhl.........

Counting Correctly!
I want to ORDER BY on a column. Straightforward until I discovered that MySQL doesn't count the same way I do.

My values are

TA1
TA2
TA3
TA4
TA5
TA6
TA7
TA8
TA9
TA10
TA11
TA12
TA13
TA14

When I ORDER BY, MySQL thinks TA10 is less than TA2,

Resulting in

TA1
TA10
TA11
TA12
TA13
TA14
TA2
TA3
TA4
TA5
TA6
TA7
TA8
TA9

I know a simple solution would be to rename my codes TA01, TA02 etc, but I can't as the values are an external code that we have to use.

Is there a way I can get MySQL to ORDER BY correctly on these values?

Results Not Sorting Correctly
I have a query where there is an hours field and a minutes field, both int fields. These two fields have the following values
Hours, Minutes
18, 13
21, 9
21, 13
21, 14

SELECT * FROM video ORDER BY hours ASC, minutes ASC

The above order that I gave the values in is the order they pull back in from that query.

Definedsize Not Reporting Correctly?
I'm connecting to a MySQL DB (4.0.26-nt) using ODBC in ASP and trying to use AddNew to add records to some tables.

When assigning longer string values to a varchar field, I get the dreaded "Multiple-step operation generated errors. Check each status value." error. I know that this is related to trying to stuff too much data into a field, but...

Here's the funny thing -- when I check a field's defined size using:
rs(myFieldName).definedsize, it reports a number smaller than when I view the design of the table within MyPHPAdmin. That is, the field is a varchar(70), but definedsize gets reported as 50. Therefore my string of 60 characters won't fit and I get the error.

Increasing the field's size doesn't change the reported definedsize... unless I drop the table and re-create.

This is all on my ISP's server, so don't know if it's something they can deal with or not?

How To Load A Dump File Correctly?
i made a dump file of my database, but now i'm not able to laod it. for testing i dropt a table and changed some data. but now, after i load the dumpfile with

mysqldump -u root ifixdb < meindump.sql

the database didn't change. there is still the table deleted and the prepared datas are still changed. how do i load the dumpfile corretly? (or should i say the dumb-file ;

How To Show Chinese Character Correctly?
i'm using Mysql5.0 now, it's char_set is latin_1 and my os is WinXP Chinese Edition. In my tables, chinese characters can be shown correctly from mysql command line, but chaos when i use mysql GUI tools and phpMyAdmin. what's wrong? what should i do ?

Mysqldump Or Import Does Not Work Correctly
@first, here are my stats:
- win2k3 / MySQL 5.0.37
- AIX 5.2 / MySQL 5.0.26

I am not a real newbie but not a crack, too ... Well, I try to replicate my db from a win2k3 server to a AIX 3.2 Server, but it doesn#t work correctly ...

I am using cacti tool for displaying my data as graphs ... and now I want to copy my data regulary from one machine to the other ...

this is the way I do this:

mysqldump cacti --user=root -p > cacti.dump
**copy via ftp**
mysql --user=root -p cacti < cacti.dump

There are no error messages displayed, but I do only have some "old" data from months ago in my cacti db, but the original db is filled up to date ...

What might be the problem ? Overwriting all files in $MYSQL_HOME$/data/cacti didn't work, too ... Is this a problem with the application perhaps, that data is different between windows and AIX ?

MySQL Server's Socket Is Not Correctly Configured?
After installing Tiger on my mac mini mySQL is all to pot.

Keep getting the message #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)"

Sort Not Handling Negative Numbers Correctly
In the table in my database I have a column of numbers ranging from -3.3 to 7.1. When I sort the column using (SELECT * FROM mytable ORDER BY mytable;) the column gets sorted as follows: -1.9, -3.3, 1.7, 2.2, 7.1 I streamlined the list as there are actually over 500 numbers between -3.3 and 7.1. The problem I am having is that when I SORT mysql is recognizing -1.9 as a smaller number than -3.3.

When I try to find the minimum number in the column using (SELECT MIN(mycolumn) FROM mytable;) mysql also displays -1.9 as the minimum number.

Is this a known problem with mysql or am I doing something wrong?

Form Contents Not Displaying Correctly In Database.
I have a webform that is submitting data that 1st gets sent to the database (using $_POST varibles) and then i build an email message and use the same $_POST varibles to create the body.

The problem im having is that when some one copies, from another form, numbers that are colored and pastes it into my form it gets submitted to the database as a different number than what was pasted. To futher confuse you, the email message shows the correct number but the database does not.

Root Login Does Not Work Correctly Without -h Option
For example, I would expect to be able to sign in by using.

mysql -u root -p

The above gives me accessed denied.

Now, I need to do.

mysql -h <hostname> -u root -p

It seems like a simple problem that I have not been able to solve by searching here and google.

Query Order By
I haven't done this sort of query before so looking for a bit of guidance!

I have a table call members and a table call event_bookings. This is for an event management system i am developing.

I want to be able to display a listing of all members who have booked into an event, but display them by surname.

The database structure is

MEMBERS TABLE
member_id
firstname
surname

EVENT_BOOKINGS TABLE
booking_id
member_id
event_id

The query without ordering it would be some
"SELECT member_id FROM EVENT_BOOKINGS WHERE event_id = '$e'"

How would I add an order by to sort this acording to the members surname...


Order By Query
We recently changed servers for a bunch of clients and this new server is running MySQL 4.1.22. A bunch, if not all, of all queries which consist of ORDER BY statements are failing to order as they should. Below is a sample of our code that worked fine on our previous server but now is giving us problems.

$query = "SELECT * FROM jobs WHERE status = 'active' ORDER BY 'date_full' DESC";
$result = mysql_query($query) or die (mysql_error());

I believe I have pinpointed the issue to the 'date_full' DESC part as if I remove the single quotes, the query works properly.

My problem is that we have alot of clients and we've used this type of query for a ton of sites. Before I go through each and every site to remove the single quotes, is there any other solution?

Query: Order By Price?
I have been wracking my brain for too long on this. Usually when you are thinking about something too long you miss the easy answer.

Essentially I need to order a query by the price of the items:

SELECT * FROM items ORDER BY itemprice

Great but... when there is a sale... the itemprice is not correct you need the sale price. I have a digit on/off field for this:

itemprice decimal(9,2)
itemsale tinyint(1)
itemsaleprice decimal(9,2)

When the item is on sale itemsale is 1 and itemsaleprice is used instead of itemprice.

Question is how do I order by all the current prices whether the item is on sale or not (and still include the sale prices where the item is on sale)?

How Can I Do Proximity Order In Query?
I am writing a search engine that uses mysql to keep a word index. I have just added the "position" of each word, in relation to the document it is in.

My table thus is as follows:

Order Query Results
Regarding a dummy set of data below,

ID Status
1 Open
2 Closed
3 Expired
4 Closed
5 Open
6 Cancelled
7 Expired
8 Cancelled

I want to view the results but order them according to the status.
i.e. i want to view in order of Open, Closed, Expired, Cancelled
I can only think of a long drawn out way by which i would create the four seperate queries.

Help With Query: Order By Association Count
Allright, here are my tables:
Posts:
id | title | text
Comments
id | post_id | name | comment
Basically one post may have many comments. Now, how would I select the 10 posts with most comments, and if only 5 posts contained comments (but there are in fact 10 posts) how could I make this query still return a total of 10 posts?



This Query Freezes When Adding ORDER BY
I have this table join statement and it works great, except when I try to order the results. When I add the ORDER BY call to the equation it freezes the browser. Alone without the ORDER BY it works fine

SELECT u.id
, u.username
, p.user_id
, p.report_id
, r.id
, r.company
, r.description
, r.market1
, r.market2
, r.market3
, r.market4
, r.market5
, r.market6
, r.location
, r.date_year
, r.date_month
, r.source
, r.video
, r.audio
, r.pp
, r.profile
, r.execsum
, r.report_url
, r.exec_url
, r.keywords
FROM user as u
INNER
JOIN user_reports as p
ON p.user_id = u.username
INNER
JOIN emt_report as r
ON r.id = p.report_id
WHERE username = '$username'
AND
MATCH (r.company, r.description, r.keywords) AGAINST (''$P_search'' IN BOOLEAN MODE) ORDER BY date_year DESC, date_month DESC, company ASC // this ORDER BY when added freezes the search.

Reversing Query Results (not The Same As ORDER BY)
I am trying to reverse the order in which the results of my query are given.

I am tweaking a gallery. I need to get the previous 3 pics based on the pic I am looking at.

The following code is a simplified version of what I have. The problem is, when I echo the results, the thumbnails are displayed in DESC order (i need them to display in ASC order) but if I order the query using ASC, the query gets the wrong images.

SELECT pic_id
WHERE pic_id < $current_pic_id
ORDER BY pic_id DESC
LIMIT 3
I need the results to show like this:
oldest pic | older pic | old pic | current pic | new pic | newer pic | newest pic

I've got the new pics sorted out but the old pics are causing a little problem...

So basically, is there a way that I can reverse the results of my query?

Mixed ORDER BY Query Results
Is there a way to order a query result a specific way?

For instance, I'm querying using

WHERE id IN(23, 25, 19)
I would like the results to stay in that order instead of by ASC or DESC.
Is this possible?

Random Query, How To Keep Sort Order Locked?
PHP Version 5.1.6 - mySQL 5.0.22

Let's pretend we have 100.000 rows in a table (all containing images with details), and I want to display 100 images at a single frontend page, but randomly retrieved and keeping the sort order once initiated to a user session.

With the normal RAND function, you have a chance to stumble on the same images when you navigate to the next page with again 100 items on. But even worse, going back to page 1, will return totally different results, and will freak out the viewer

How to get a (fake) random listing on a fairly large database, where every requested row is unique, and the sort order is being locked (until you press a randomize button ie, or start a new session) while keeping speed in mind (so trying to avoid reading out all rows up front).

Query - Top 20 Results In Ascending Alphabetical Order
I have a table which is a list of categories in an online directory.. each time the category is visited in increases the hits column by one..

I want to get the top 20 results (ie. the top twenty most popular categories) and then sort them into a list alphabetically.

I tihnk I have to use a nested select but when I do this I only get the top 20 results sorted by alphabet not by hits..

Here is the table structure:

CODE#
# Table structure for table `category`
#

CREATE TABLE category (
autoID mediumint(9) NOT NULL auto_increment,
title varchar(100) NOT NULL default '',
hits int(11) NOT NULL default '0',
PRIMARY KEY (autoID)
) TYPE=MyISAM;

Grouping For A Query And Limiting Returned Data In Order Of IN()
I'm trying to pull some data from the database in which it's supposed to return 3 rows from each f.forumid in the order in which i have the forumids, however it seems to be returning all the data from the table, what am i doing wrong?

PHP Code:

SELECT t.threadid, t.title, t.lastpost, t.forumid, t.open, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, t.firstpostid, f.title AS forumtitle, p.pagetext AS preview
    FROM thread t
    INNER JOIN forum f ON (t.forumid = f.forumid) AND t.visible = 1
    LEFT JOIN post p ON(p.postid = t.firstpostid)
    WHERE t.forumid IN(200,250,2,30,15,60,70,90)
    GROUP BY f.title, t.title
    HAVING COUNT(*) <= 3
    ORDER BY f.forumid, t.dateline DESC

Changing Order Of Columns Using Mysql Query Browser
I have a table that is already created and I wanted to add a column, but put it somewhere in the middle of the table. is there a drag and drop (or something just as easy) method to move it up in the table? or do I have to re-create the whole table?

Truncated Time Values Using TIMEDIFF With ORDER BY Query
I'm using the following query:

SELECT glider, timestamp, TIMEDIFF(timestamp, UTC_TIMESTAMP()) AS last_contact
FROM surfacings
INNER JOIN
(SELECT MAX(timestamp) AS most_recent FROM surfacings GROUP BY glider)
AS tmp
WHERE surfacings.timestamp = tmp.most_recent;

to calculate the amount of time that has elapsed since the last inserted timestamp for each glider. Everything works fine: ....

ORDER BY WHERE + Include Rest Of Table Or ORDER? Possible?
I need to create some SQL that when run returns all the rows which a column is equal to number that has been specified, but then the query needs to return the rest of the rows in the table. How could this be done? is it even possible? Is their order syntax that could do this better?

Multiple ORDER & SUB ORDER On The Same MySQL Table
I am trying to do multiple ORDERS or SUB ORDERS on the same MySQL table, and I'm loosing my mind trying to fathom the logic and SQL statement to use, I'm no MySQL genius! more a newbie.

*** SEE ATTACHED IMAGE PLEASE

I have tried all sorts of SQL statements, e.g:

SELECT * FROM categories GROUP BY parent ORDER BY order, parent DESC

Nothing seems to work.

I think my only solution is to do a bubble-sort after putting the whole table in a PHP ARRAY ?

I'd also like the menu to act like the + pop-open sub-menu boxes on the Forum left column menu.

How To ORDER BY DESC Properly. It Makes 150 Before 50 If ASC Order!?
I have this list:
50
150
200
250
300
350
400
450
500

If I order it by ASC order then mysql results this:
150
200
250
300
350
400
450
50
500

What the hell ?? How do I order it properly?

How To Query Records That Have Same Words But Maybe Different Words Order?
I am trying to find a way to do a select query that can find records that have same words in any orders. e.g. "hello good morning", "good hello morning", "morning good hello"... they should all returned by the select query.

Please don't tell me that I can use "or" inside select query. It's because what if the string has 10 words? There are tons of permutations.

How Does MySQL Order Records With No ORDER BY?
If you don't specify an ORDER BY clause, how does MySQL order the records? Is it just the order in which they found in the database?

!= Not Working?
SELECT

d.cache_diff,
d.cache_name,
d.cache_type,
d.cache_last_found

FROM geocaches d
LEFT JOIN logvisit ON d.cache_id=logvisit.cache_id
WHERE d.cache_status = 0 && logvisit.log_type != 'Found' && logvisit.log_owner_id = 64

This returns zero rows. Its true that records in logvisit.log_type for this user are only FOUND but I am trying to display cache information for all other caches (in geocaches table) that the user did not log FOUND in logvisit.

So, basically if the user logged against 3 caches and there are 10 caches available to log agains then I want to display only the remaining 7. Is JOIN the way to go on this one?

LIKE '[0-9]%' Not Working
Here is the SQL query:


Code:

SELECT * FROM member WHERE username LIKE '[0-9]%'



Returns 0 rows. I've tried this on 4.1.7-nt as well as 4.0.22-standard; neither work. And yes, there are records in the table that should match that pattern.

Not Working
I have 4.1.10a on my local machine and the following WHERE clause works fine:
Code:

WHERE wk1 IN (select max(wk1) from wkpts where teamid = w.teamid)

But when I upload it to my web site, I get an sytax error at 'select max(wk1) from...'
My web host has MySQL version 4.0.20-standard.
Can someone tell me why it would work locally, but not on my web host's server? Thank you.

LIKE '%$var%' Not Working
I am trying to create an sql statement to return values on either side of the variable.
Code:

$sql = "SELECT * FROM principals LIKE companyName = '%{$_POST['companyName']}%'";

The error was:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE companyName = '%Mike%'' at line 1

Select As Where Not Working!


SELECT CONCAT(RIGHT(dt,4),'-',MID(dt,4,2),'-',LEFT(dt,2)) AS dateavail FROM atable WHERE dateavail = &#55614;&#57158;-06-01'

(dt is a date in format dd/mm/yyyy - the concat bit works fine)

Microsoft OLE DB Provider for ODBC Drivers error ?e14'

[MySQL][ODBC 3.51 Driver][mysqld-4.1.19-standard-log]Unknown column 'dateavail' in 'where clause'

Also, if I get it to work, how do I convert the 2 strings to date so I can look for < and > ?


Doing A JOIN Not Working
I have 2 tables, one contains columns that holds the ID to the other table so eg

Table 1 (images)
id | imagepath
--------------
1 dir/hair.png
2 dir/face.png

Table 2 (buildImages)
userid | hair | face
1 1 2

So i'd just like to retrieve a row like

dir/hair.png, dir/face.png

where userid = 1

does that make sense?
Oh, the title of this thread is kind of wrong, shoudl be how do I do this join :P

DATE_SUB() Is Not Working Right For Me.
My `date` column is in date/time format 2007-12-14 19:55:00
When I try to select only the records added in the last 5 hours, I get records from more than 24 hours ago. I know I am EST zone and the server is PST zone, but something else is wrong. This is my WHERE clause:

WHERE `date` > DATE_SUB(CURRENT_DATE, INTERVAL 5 HOUR)

Working With SET Type ...
I have this SET(&#391;',&#392;',&#393;',&#394;') on a column. Suppose that the colunm has the data (1,2,4)
Now i want to select rows that contain either 1 or 2 or 4. What is the fastest way to do this ?

Left(str. Len) Not Working!
BTW: I am very new to PHP & MySQL learning from the site point book ("Build your own database driven website!").

My Question
If i use the left function from the command line, the expected result is returned ok, however when i apply the same query to my web page nothing is returned.

This is my query:
$sql = "SELECT date_added, short_desc, LEFT(long_desc, 10), news_ID, loc_id FROM location Inner Join news ON globalisation = loc_id WHERE loc_id = &#391;' ORDER BY news_ID ASC";

$getRows = @mysql_query($sql);
if (!$getRows)
{
exit('Error: Loading SQL statements: '.mysql_error());
}
while($listedItems = mysql_fetch_array($getRows))
{
$id = htmlspecialchars($listedItems['news_ID']);
$news_short = htmlspecialchars($listedItems['short_desc']);
$news_long = htmlspecialchars($listedItems['long_desc']);
$date_added = htmlspecialchars($listedItems['date_added']);
echo '<div class="row_container">'
echo '<div class="col_1">' . htmlspecialchars($id) . '</div>'
echo '<div class="col_2">' . htmlspecialchars($news_short) . '</div>'
echo '<div class="col_3">' . htmlspecialchars($news_long) . '</div>'
echo '<div class="col_4">' . htmlspecialchars($date_added) . '</div>'
echo '<div class="col_5"><a href="edit_news.php?id=' . $id .'">Edit<a/></div></div>'
}



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