Multiple rows in single where … like clauseMultiple Updates in MySQLHow to concatenate text from multiple rows into a single text string in SQL server?Can I concatenate multiple MySQL rows into one field?Parameterize an SQL IN clauseSQL join: where clause vs. on clauseInserting multiple rows in a single SQL query?INNER JOIN ON vs WHERE clauseIs it possible to insert multiple rows at a time in an SQLite database?How to query MongoDB with “like”?Select first row in each GROUP BY group?

How do I tell my girlfriend she's been buying me books by the wrong author for the last nine months?

Why would Dementors torture a Death Eater if they are loyal to Voldemort?

Why is numpy sometimes slower than numpy + plain python loop?

Why did the Apple //e make a hideous noise if you inserted the disk upside down?

Subset of knight's move in chess.

ESTA Elegible after Qatar?

Magento2: Custom module not working

Does a lens with a bigger max. aperture focus faster than a lens with a smaller max. aperture?

Do electrons really perform instantaneous quantum leaps?

Where to connect the fuse and why?

Russian equivalents of 能骗就骗 (if you can cheat, then cheat)

Fully submerged water bath for stove top baking?

Did the Russian Empire have a claim to Sweden? Was there ever a time where they could have pursued it?

A finite 2 group containing the dihedral group of order 16?

Should Catholics in a state of grace call themselves sinners?

"I am [the / an] owner of a bookstore"?

Examples of a lower energy state being a lower entropy state?

What is the meaning of 'shout over' in a sentence exactly?

Word ending in "-ine" for rat-like

Dynamic Sql Query - how to add an int to the code?

Active wildlife outside the window- Good or Bad for Cat psychology?

Why was Pan Am Flight 103 flying over Lockerbie?

What was the point of separating stdout and stderr?

Can I take Amul cottage cheese from India to Netherlands?



Multiple rows in single where … like clause


Multiple Updates in MySQLHow to concatenate text from multiple rows into a single text string in SQL server?Can I concatenate multiple MySQL rows into one field?Parameterize an SQL IN clauseSQL join: where clause vs. on clauseInserting multiple rows in a single SQL query?INNER JOIN ON vs WHERE clauseIs it possible to insert multiple rows at a time in an SQLite database?How to query MongoDB with “like”?Select first row in each GROUP BY group?













0















I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:



$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


or:



$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


Or do i have to use it like that:



$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";









share|improve this question
























  • Try something like the ANY(array) operator...

    – Usagi Miyamoto
    Mar 25 at 15:56











  • ANY() will not work...

    – Usagi Miyamoto
    Mar 25 at 16:08















0















I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:



$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


or:



$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


Or do i have to use it like that:



$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";









share|improve this question
























  • Try something like the ANY(array) operator...

    – Usagi Miyamoto
    Mar 25 at 15:56











  • ANY() will not work...

    – Usagi Miyamoto
    Mar 25 at 16:08













0












0








0








I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:



$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


or:



$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


Or do i have to use it like that:



$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";









share|improve this question
















I am trying to create a search-form and am tring to search in multiple rows/ concatenated rows. Is there a way to use something like the following code:



$where = "
WHERE
(
s.companyName,
s.companyName || s.companyType,
s.companyName || s.companyLocationType,
s.companyLocationName,
s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


or:



$where = "
WHERE
(
s.companyName
OR s.companyName || s.companyType
OR s.companyName || s.companyLocationType
OR s.companyLocationName
OR s.companyLocationName || s.companyLocationType
) LIKE (".$val.")
";


Or do i have to use it like that:



$where = "
WHERE
s.companyName LIKE (".$val.")
OR s.companyName || s.companyType LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
OR s.companyLocationName LIKE (".$val.")
OR s.companyName || s.companyLocationType LIKE (".$val.")
";






sql postgresql where sql-like






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 15:49









Jared Forth

8371 gold badge5 silver badges20 bronze badges




8371 gold badge5 silver badges20 bronze badges










asked Mar 25 at 15:35









GrimGrim

228 bronze badges




228 bronze badges












  • Try something like the ANY(array) operator...

    – Usagi Miyamoto
    Mar 25 at 15:56











  • ANY() will not work...

    – Usagi Miyamoto
    Mar 25 at 16:08

















  • Try something like the ANY(array) operator...

    – Usagi Miyamoto
    Mar 25 at 15:56











  • ANY() will not work...

    – Usagi Miyamoto
    Mar 25 at 16:08
















Try something like the ANY(array) operator...

– Usagi Miyamoto
Mar 25 at 15:56





Try something like the ANY(array) operator...

– Usagi Miyamoto
Mar 25 at 15:56













ANY() will not work...

– Usagi Miyamoto
Mar 25 at 16:08





ANY() will not work...

– Usagi Miyamoto
Mar 25 at 16:08










1 Answer
1






active

oldest

votes


















0














WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)


etc. will work if you're looking for an exact match rather than using LIKE.






share|improve this answer























  • this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

    – Grim
    Mar 25 at 16:26











  • In that case you might want to go with your last example, since you're comparing each different input to a pattern

    – anonymous
    Mar 25 at 17:06










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55341357%2fmultiple-rows-in-single-where-like-clause%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)


etc. will work if you're looking for an exact match rather than using LIKE.






share|improve this answer























  • this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

    – Grim
    Mar 25 at 16:26











  • In that case you might want to go with your last example, since you're comparing each different input to a pattern

    – anonymous
    Mar 25 at 17:06















0














WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)


etc. will work if you're looking for an exact match rather than using LIKE.






share|improve this answer























  • this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

    – Grim
    Mar 25 at 16:26











  • In that case you might want to go with your last example, since you're comparing each different input to a pattern

    – anonymous
    Mar 25 at 17:06













0












0








0







WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)


etc. will work if you're looking for an exact match rather than using LIKE.






share|improve this answer













WHERE (".$val.") in (s.companyName | s.companyType,s.companyName | s.companyLocationType)


etc. will work if you're looking for an exact match rather than using LIKE.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 15:59









anonymousanonymous

182 bronze badges




182 bronze badges












  • this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

    – Grim
    Mar 25 at 16:26











  • In that case you might want to go with your last example, since you're comparing each different input to a pattern

    – anonymous
    Mar 25 at 17:06

















  • this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

    – Grim
    Mar 25 at 16:26











  • In that case you might want to go with your last example, since you're comparing each different input to a pattern

    – anonymous
    Mar 25 at 17:06
















this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

– Grim
Mar 25 at 16:26





this looks good and will be used on different occasions. But i will have to use LIKE in this case here as i will accept %/_-parameters for special searches too. And those dont work in in exact matches, do they? eg.: %c_b% finds facebook fpr example

– Grim
Mar 25 at 16:26













In that case you might want to go with your last example, since you're comparing each different input to a pattern

– anonymous
Mar 25 at 17:06





In that case you might want to go with your last example, since you're comparing each different input to a pattern

– anonymous
Mar 25 at 17:06






Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55341357%2fmultiple-rows-in-single-where-like-clause%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해