Jump to content
php.lv forumi

divas tabulas bet kārto tikai pēc vienas


sega99

Recommended Posts

Jautājums, ko tu vispār vēlies panākt? atlasīt 10 audi un 10 bmw?

select t1.title, t2.title FROM
( SELECT DISTINCT audi.title FROM audi ORDER BY audi.dateadded DESC ) t1, ( SELECT DISTINCT bmw.title FROM bmw ORDER BY bmw.date DESC ) t2
LIMIT 10;

Iespējams šitas strādās :)

Link to comment
Share on other sites

(
	( SELECT 'audi' as `type`, audi.title as title, audi.dateadded as added FROM audi ORDER BY audi.dateadded DESC LIMIT 10 )
	UNION
	( SELECT 'bmw' as `type`, bmw.title as title, bmw.date as added FROM bmw ORDER BY bmw.date DESC LIMIT 10 )
);

 

Šitā vajadzētu strādāt pareizi, vienīgi, ir nevis labā un kreisā puse, bet pielikta kolona tips.

Un vispār mašīnas vajadzētu glabāt vienā tabulā, un vienkārši pielikt papildus lauku ražotājs.

Edited by draugz
Link to comment
Share on other sites

 

(
	( SELECT 'audi' as `type`, audi.title as title, audi.dateadded as added FROM audi ORDER BY audi.dateadded DESC LIMIT 10 )
	UNION
	( SELECT 'bmw' as `type`, bmw.title as title, bmw.date as added FROM bmw ORDER BY bmw.date DESC LIMIT 10 )
);

 

Šitā vajadzētu strādāt pareizi, vienīgi, ir nevis labā un kreisā puse, bet pielikta kolona tips.

Un vispār mašīnas vajadzētu glabāt vienā tabulā, un vienkārši pielikt papildus lauku ražotājs.

klausos ser un sanaca ! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...