Главная страница
    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.039 c
15-1161542096
Belorus
2006-10-22 22:34
2006.11.12
Профайлер...


15-1161879231
Витян
2006-10-26 20:13
2006.11.12
Подскажите алгоритм, который подошел бы для данной задачи на граф


2-1161775849
KyRo
2006-10-25 15:30
2006.11.12
Код Enter


15-1161417911
vidiv
2006-10-21 12:05
2006.11.12
Посоветуйте: как реализовать -


2-1161839521
md
2006-10-26 09:12
2006.11.12
procedure





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский