PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > with ORDER BY
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
with ORDER BY

Réponse
 
LinkBack Outils de la discussion
Vieux 11/09/2007, 13h25   #1
Pedro Mpa
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut with ORDER BY

Hi all!

I need some with ORDER BY in the following example. I want to order by
selected category, then by subcategories of the selected category, then by
categories with the same parent_id of the selected category, then by random
if possible, or random within the categories if possible, but the first
order by part is not working because is not returning products of the
selected category first, instead returns products from a top category
(parent_id = 0).

table categories
id | parent_id | category
- where parent_id is 0 for top categories.

table products
id | id_category | product

SELECT
products.id,
(SELECT
CASE WHEN CHAR_LENGTH(products.product) > 40 THEN
CONCAT(SUBSTRING(products.product,1,37),'...')
ELSE products.product END) AS product,
(SELECT
CASE WHEN CHAR_LENGTH(products.description) > 70 THEN
CONCAT(SUBSTRING(products.description,1,67),'...')
ELSE products.description END) AS description
FROM
products
WHERE
products.id_stock = 1
ORDER BY
products.id_category IN (".$id_selected_category."
, (SELECT categories.id
FROM categories
WHERE categories.parent_id = ".$id_selected_category.")
, (SELECT categories.id
FROM categories
WHERE categories.parent_id = ".$parent_id."))
, RAND() LIMIT 11

(the php vars have correct values)

Please apologise my bad English.
Thanks in advance.
Pedro.


  Réponse avec citation
Vieux 11/09/2007, 15h11   #2
WiNK / Rob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: with ORDER BY

Hi ,

I think i might have hit a bug, posted on forums.mysql.com but
apparently nobody really reads that i think.

my table:

CREATE TABLE `clog` ( `cID` int(20) NOT NULL auto_increment, `lID`
int(10) default NULL, `ip` int(10) default NULL, `timestamp` int(11) NOT
NULL, PRIMARY KEY (`clickID`) ) ENGINE=MYISAM; or i use ARCHIVE

I have a bit of a problem that occurs only when i change my really
simple log table to the archive engine. The replication breaks. Any
thoughts? The row number of the error is variable. When the table is set
to myisam, the replication does not break on duplicate key, and runs as
expected.

Can't write; duplicate key in table 'clog'' on query.

Is it possible that due to the stress of the benchmark, my slave cannot
compute the next cID or creates a duplicate (cId is the only variable
that changes, on bench query)?


  Réponse avec citation
Vieux 11/09/2007, 15h42   #3
WiNK / Rob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut archive engine potential bug

W00ps forgot to update subject of my email,

WiNK / Rob wrote:
> Hi ,
>
> I think i might have hit a bug, posted on forums.mysql.com but
> apparently nobody really reads that i think.
>
> my table:
>
> CREATE TABLE `clog` ( `cID` int(20) NOT NULL auto_increment, `lID`
> int(10) default NULL, `ip` int(10) default NULL, `timestamp` int(11)
> NOT NULL, PRIMARY KEY (`clickID`) ) ENGINE=MYISAM; or i use ARCHIVE
>
> I have a bit of a problem that occurs only when i change my really
> simple log table to the archive engine. The replication breaks. Any
> thoughts? The row number of the error is variable. When the table is
> set to myisam, the replication does not break on duplicate key, and
> runs as expected.
>
> Can't write; duplicate key in table 'clog'' on query.
>
> Is it possible that due to the stress of the benchmark, my slave
> cannot compute the next cID or creates a duplicate (cId is the only
> variable that changes, on bench query)?
>
>
>




  Réponse avec citation
Vieux 11/09/2007, 15h44   #4
Michael Dykman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: with ORDER BY

Thing 1: your auto_increment key MUST be your primary key.

Thing 2: the timestamp field will be updated with the current epochal
timestamp which only increments every second.. as you have a
timestamp field as you primary (and therefore unique) key, you will
never be able to perform more than one INSERT/UPDATE within the span
of any given second.

you need to redign the table, I'm afraid.

On 9/11/07, WiNK / Rob <wink@connectedserver.com> wrote:
> Hi ,
>
> I think i might have hit a bug, posted on forums.mysql.com but
> apparently nobody really reads that i think.
>
> my table:
>
> CREATE TABLE `clog` ( `cID` int(20) NOT NULL auto_increment, `lID`
> int(10) default NULL, `ip` int(10) default NULL, `timestamp` int(11) NOT
> NULL, PRIMARY KEY (`clickID`) ) ENGINE=MYISAM; or i use ARCHIVE
>
> I have a bit of a problem that occurs only when i change my really
> simple log table to the archive engine. The replication breaks. Any
> thoughts? The row number of the error is variable. When the table is set
> to myisam, the replication does not break on duplicate key, and runs as
> expected.
>
> Can't write; duplicate key in table 'clog'' on query.
>
> Is it possible that due to the stress of the benchmark, my slave cannot
> compute the next cID or creates a duplicate (cId is the only variable
> that changes, on bench query)?
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=mdykman@gmail.com
>
>



--
- michael dykman
- mdykman@gmail.com

- All models are wrong. Some models are useful.
  Réponse avec citation
Vieux 12/09/2007, 04h19   #5
Rob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: archive engine potential bug

also when it hits a dupl. and i skip the record, and continue slave it
hits another duplicate entry almost instantly, when i then drop the
table on the slave, and recreate it manually and set it to myisam at
that time, the slave continues without a problem.


On Tue, 2007-09-11 at 16:42 +0200, WiNK / Rob wrote:
> W00ps forgot to update subject of my email,
>
> WiNK / Rob wrote:
> > Hi ,
> >
> > I think i might have hit a bug, posted on forums.mysql.com but
> > apparently nobody really reads that i think.
> >
> > my table:
> >
> > CREATE TABLE `clog` ( `cID` int(20) NOT NULL auto_increment, `lID`
> > int(10) default NULL, `ip` int(10) default NULL, `timestamp` int(11)
> > NOT NULL, PRIMARY KEY (`clickID`) ) ENGINE=MYISAM; or i use ARCHIVE
> >
> > I have a bit of a problem that occurs only when i change my really
> > simple log table to the archive engine. The replication breaks. Any
> > thoughts? The row number of the error is variable. When the table is
> > set to myisam, the replication does not break on duplicate key, and
> > runs as expected.
> >
> > Can't write; duplicate key in table 'clog'' on query.
> >
> > Is it possible that due to the stress of the benchmark, my slave
> > cannot compute the next cID or creates a duplicate (cId is the only
> > variable that changes, on bench query)?
> >
> >
> >

>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=m...ctedserver.com
>
>



--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h55.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12289 seconds with 13 queries