2011-09-07 4 views
1

두 테이블에서 데이터를 가져옵니다. 하지만 난 별개의 키워드가 별개의 기록을 얻으려면, 그래서 내가 원치 않는 repeatation를 얻고 있지만 오류가SQL 고유 키워드 문제

SELECT distinct fb_event.id AS rid, fb_event.eventname AS sevntname, 
    fb_event.location AS slocation, fb_event.startdate AS sstartdate, 
    fb_event.enddate AS senddate, 
          cast(fb_event.CATEGORY as text) AS sCATEGORY, cast(fb_event.tags as text) AS stags, 
               cast(fb_event.description as text) AS sdescription, 
              cast(fb_event.eventid as text) AS seventid, 
              cast(fb_event.city as text) AS scity, cast(fb_event.venue as text) AS svenue, 
              cast(fb_event.country as text) AS scountry, cast(fb_event.postalcode as text) AS spostalcode, 
              cast(fb_event.keyword as text) AS skeyword, 
          cast(fb_userevents.userid as text) AS suserid,fb_event.longitude as long, fb_event.altitude as alt,fb_event.attending 
    FROM fb_event INNER JOIN 
    fb_userevents ON fb_event.eventid = fb_userevents.eventid order by fb_event.eventid 

작동하지 않았다 메시지 145, 수준 15, 상태 1, 줄 1 항목 BY ORDER가 나타나야합니다 SELECT DISTINCT가 지정되면 선택 목록에 표시됩니다.

내가 누락되었습니다. 어떤 종류의 도움이라도 대단히 감사하겠습니다.

+1

선택 목록에 ** b_event.eventid **가 있어야합니다. –

+0

검색어에'Order By '를 사용해야 할 수도 있습니다. 이 기사를보십시오 –

답변

0

astlander에 따르면 특정 필드로 주문하는 경우 해당 필드는 select 문에 나열되어야합니다. * fb_event.eventid *를 선택 항목에 추가하면 select 문이 정상적으로 작동합니다.

+0

이것은 이미 포함되어 있습니다 : cast (fb_event.eventid as text) AS seventid, – Janu

+0

@Janu - SQL Server에 관한 한 'cast (fb_event.eventid as text) <> fb_event.eventid'입니다. 주문을'ORDER BY cast (fb_event.eventid as text)'로 변경하거나'fb_event.eventid'를 선택 항목에 추가하십시오. –

+0

당신보다 @ 실례합니다. 그렇습니다. 나는 그것을 점검 할것이다 – Janu