는 방법을 찾기 위해 특정 일에는 테이블레스 라이브러리에 해당하는 개발용

0

질문

나는 현재 사용하여 그레스에 액세스하면 그것을 통해 노드는 서버입니다.

나는 느낌이에 붙어있는 것과 방법을 검색에 대한 특정 기간 내에 테이블을 만들기 위해 변경됩니다. 내가 알고 선택할 수 있는 특정 항목만,나는 알지 못하는 방법에서 검색 항목입니다.

내 테이블:

무서운
중간 개 no
no
무성한 개 no
큰 개
큰 고양이 no
작은 물고기 no no

갑자기 나는 비트에 의해 개,그리고 지금 나는 모든 것을 변경하려면을 포함하는'개|개'무서운:그렇습니다.

나는 정말 못 찾는 모든 좋은 자료를 만드는 기능입니다. 아마도 내가 간과 무언가이다.

지금 내가 사용하여 간단한 선택과 같다:

app.get('/update/:type', (req, res) => {
  pool.query("SELECT animal FROM petlist WHERE scary = 'no' AND animal = $1",[req.params.client],
   (error, results) => {
    if (error) {
      console.log("I selected dog, but I can't see the specific types of dog!")
      throw error
      }
    console.log(results.rows);
    res.status(200).json(results.rows)
  })
});
javascript node.js postgresql sql
2021-11-24 02:38:38
1

최고의 응답

2

내가 알지 못하 obscurification 언어(및 라이브러리)하지만 그레스 조건자 당신이 찾고있는 것 중 하나가 될 또는 경우에 변환의 열 animal. 그래서

select animal 
  from petlist 
 where scary = 'no' 
   and animal ilike '%dog'; 

-- or if nodejs complains about ilike then 
select animal 
  from petlist 
 where scary = 'no' 
   and lower(animal) like '%dog'; 

그래서 아마도 다음과 같습니다.

app.get('/update/:type', (req, res) => {
  pool.query("SELECT animal FROM petlist WHERE scary = 'no' AND animal ILIKE $1,[req.params.client],
   (error, results) => {
    if (error) {
      console.log("I selected dog, but I can't see the specific types of dog!")
      throw error
      }
    console.log(results.rows);
    res.status(200).json(results.rows)
  })
});

와 req.params.클라이언트가 설정한 문자열에 %개.

2021-11-24 23:06:34

이것은 환상적이다! 너무 감사합니다,나는에 대해 알고하지 않았다 비행. 그것은 약간의 고통을 얻는 라이브러리에 해당하는 개발용을 통과하는 올바른 기간으로는 아포스트로피와 비율을 표시지만 결국 거기고,그것은 완벽하게 작동합니다. 감사합니다.
SGPascoe

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................