Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Базы";
Текущий архив: 2006.11.12;
Скачать: [xml.tar.bz2];

Вниз

вложенный запрос   Найти похожие ветки 

 
syte_ser78 ©   (2006-09-15 11:02) [0]

и SqlExplorer и компилятор Delphi не хочет обработать следующий вложенный запрос

sqlTemp.SQL.Text:="

select topics.title
from (
      select distinct topics.title, posts.post_date
        from topics, posts
       where (topics.tid=posts.topic_id)
     )
order by topics.title desc

";

Как его можно написать по другому?


 
StriderMan ©   (2006-09-15 11:07) [1]

select distinct t.title
       from topics t JOIN posts p on (t.tid=p.topic_id)
order by t.title desc


 
Sergey13 ©   (2006-09-15 11:10) [2]

> [0] syte_ser78 ©   (15.09.06 11:02)

Что за БД м какой компилятор не хочет?


 
syte_ser78 ©   (2006-09-15 11:18) [3]

БД- парадокс. Delphi -7

Спасибо большое.
Прошу прощения. Ошибка....

Сортировать по max(posts.post_date)


 
syte_ser78 ©   (2006-09-15 11:18) [4]

извиняюсь еще раз. Пока не отвечайте, запутался совершенно


 
syte_ser78 ©   (2006-09-15 11:20) [5]

есть две таблици. Topics и Posts
Таблица posts связана с topics отношением ного к одному по полу posts.topic_id-topics.tid

нужно вывести список topic.title отсортированый по убыванию значения поля posts.post_date


 
syte_ser78 ©   (2006-09-15 11:23) [6]

select distinct topics.title
from
 (select topics.title, posts.post_date
  from topics, posts
  where topics.tid=posts.topic.id
  order by posts.post_date)


 
Sergey13 ©   (2006-09-15 11:23) [7]

> [3] syte_ser78 ©   (15.09.06 11:18)

Первый раз слышу, что компилятор Д7 "не хочет обработать вложенный запрос". 8-)


 
Sergey13 ©   (2006-09-15 11:26) [8]

> [6] syte_ser78 ©   (15.09.06 11:23)

Насколько я помню, LocalSQL не ест такие вложенные запросы.
select topics.title, max(posts.post_date)
 from topics, posts
 where topics.tid=posts.topic.id
 group by posts.post_date


 
Slym(RO)   (2006-09-15 11:33) [9]

select topics.title, posts.post_date
from topics inner join posts on topics.tid=posts.topic.id
order by posts.post_date desc;


 
syte_ser78 ©   (2006-09-15 11:39) [10]

Slym(RO)   (15.09.06 11:33) [9]
Спасибо за ответ, но опять же -

> select topics.title, posts.post_date

Нужно вывсети только distinct topics.title, а компилятор просит чтобы в select было то что есть в order by



Страницы: 1 вся ветка

Форум: "Базы";
Текущий архив: 2006.11.12;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.056 c
15-1161509757
Kerk
2006-10-22 13:35
2006.11.12
Как научить человека не искать в критической ситуации отмазки,


8-1144338190
QuickFinder
2006-04-06 19:43
2006.11.12
TShockwaveFlash и его свойство Align


2-1162037505
Ivolg
2006-10-28 16:11
2006.11.12
Пробелы


2-1161985394
markers
2006-10-28 01:43
2006.11.12
OverDraw и TreeView


15-1161338945
default
2006-10-20 14:09
2006.11.12
По мотивам двойного хеширования;)





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский