MySQL OR/AND 우선 순위
MySQL의 논리 연산자에는 쿼리에서 여러 조건이 평가되는 방식을 지정하는 특정 우선 순위 규칙이 있습니다. 효율적이고 정확한 쿼리를 작성하려면 이러한 규칙을 이해하는 것이 중요합니다.
쿼리와 관련하여 표시가 1 또는 2이고 콘텐츠, 태그 또는 제목에 "hello world"가 포함된 행을 검색하려고 합니다. MySQL 연산자의 우선순위 규칙은 다음과 같습니다.
(highest precedence) INTERVAL BINARY, COLLATE ! - (unary minus), ~ (unary bit inversion) ^ *, /, DIV, %, MOD -, + > & | = (comparison), =, >, , !=, IS, LIKE, REGEXP, IN BETWEEN, CASE, WHEN, THEN, ELSE NOT &&, AND XOR ||, OR = (assignment), := (lowest precedence)
이러한 규칙을 염두에 두고 쿼리를 분석해 보겠습니다.
Select * from tablename where display = 1 or display = 2 and content like "%hello world%" or tags like "%hello world%" or title = "%hello world%"
우선순위 규칙에 따라 논리 연산자는 괄호 안에서 평가됩니다. :
- 괄호 안: (표시 = 1) 또는 (display = 2)는 디스플레이 1 또는 2가 있는 행이 검색되도록 합니다.
- 외부 괄호: ((display = 1) 또는 (display = 2)) 및 ( "%hello world%"와 같은 콘텐츠) 또는 ("%hello world%"와 같은 태그) 또는 ("%hello world%"와 같은 제목)은 "hello"와 일치하는 조건을 정의합니다. world."
AND보다 OR가 우선하므로 쿼리는 다음과 같이 해석됩니다.
Select * from tablename where (display = 1 or display = 2) and (content like "%hello world%" or (tags like "%hello world%" or title = "%hello world%"))
따라서 쿼리는 다음과 같은 행을 검색합니다.
- 표시는 1 또는 2이고
- 콘텐츠, 태그 또는 제목에 "hello"가 포함되어 있음 world."
혼란을 피하기 위해 괄호를 사용하여 원하는 평가 순서를 명시적으로 표시하는 것이 좋습니다. 예를 들어, 다음 쿼리는 디스플레이가 1 또는 2이거나 콘텐츠, 태그 또는 제목에 "hello world"가 포함된 행을 검색합니다.
Select * from tablename where (display = 1 or display = 2) and (content like "%hello world%" or tags like "%hello world%" or title like "%hello world%")
위 내용은 MySQL은 `WHERE` 절의 `OR` 및 `AND` 연산자를 어떻게 평가합니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

todropaViewInmysql, "dropviewifexistsview_name;"및 TomodifyAview를 사용하고 "createOrreplaceViewView_NameAsselect ...". "

mysqlViewScaneFeficTicallyINGILIDESIGNPATTORNSLIKEADAPTER, DECIARATOR, FACTORY 및 OBSERVER.1) AdapterPatternAdAptSDataFromDifferentTablesinToAunifiedView.2) Decor

viewsinmysqlarebeneficialforsimplifyingcomplexqueries, envancingsecurity, dataconsistency, andoptimizing promperformance

toeteimpleviewinmysql, usethecreateviewstatement.1) definetheviewwithReateViewview_nameas.2) specifyTesLectStatementToreTrievesiredData.3) usetheViewLikeAtableForqueries.ViewsSimplifyDataAccessAndenHances, ButconSiderFormance

toCreateUserSinmysql, usethecreateuserstatement.1) foralocaluser : createUser'LocalUser '@'localHost'IndifiedBy'SecurePassword '; 2) foremoteUser : createUser'RemoteUser'@'%'reidentifiedBy'StrongPassword ';

mysqlviewshavelimitations : 1) 그들은 upportallsqloperations, datamanipulation throughviewswithjoinsorbqueries를 제한하지 않습니다

적절한 usermanagementInmysqliscrucialforenhancingsecurityandensuringfefficientDatabaseOperation.1) USECREATEUSERTOWDDUSERS,@'localHost'or@'%'.

mysqldoes notimposeahardlimitontriggers, butpracticalfactorsdeteirefectiveuse : 1) ServerConfigurationimpactStriggerManagement; 2) 복잡한 트리거 스케일 스케일 사이드로드; 3) argertableSlowtriggerTriggerPerformance; 4) High ConconcercencyCancaUspriggerContention; 5) m


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경