Does facebook fql contain the sql like operator?
There is no LIKE operator in FQL.
However, you may have luck with the IN operator:
WHERE "Stanford" IN
education_history.name
This page may also help and has sample queries:
- FQL
Facebook FQL LIKE operator
SELECT link_id from link WHERE strpos(url,'FRLJTjNC8So') >=0 AND owner = '421235'
There is no SQL LIKE
in FQL. My solution uses FQL STRPOS
instead. This works because it
searches for the substring FRLJTjNC8So
within the URL
field.
The following thread was helpful
Does facebook fql contain the sql like operator?
How can I use the LIKE operator on a map type in hiveql?
Explode map, then you can filter keys using LIKE. If you want to get single row per id_test, number
even if there are many keys satisfying LIKE condition, use GROUP BY
or DISTINCT
.
Demo:
with students as (--one record has many MOBILE* keys in the map
SELECT 123434 id_test , map('MOBILE','918-555-1162', 'OFFICE', '123456', 'MOBILE2', '5678') number union all
SELECT 245678, map('WORK','806-555-4722')
)
select s.id_test, s.number
from students s
lateral view explode(number) n as key,value
where n.key like '%MOBILE%'
group by s.id_test, s.number
Result:
123434 {"MOBILE":"918-555-1162","MOBILE2":"5678","OFFICE":"123456"}
If you know the key exactly 'MOBILE' then better to filter like this: where number['MOBILE'] is not null
, without explode.
Is there a way to use like operator with an array in HiveQL?
Concatenate array using some delimiter, for example |
and use concatenated string in RLIKE operator.
Demo:
with mytable as (
select 1 id, array('8001','12100') as `values`
union all
select 2, array('12134','9999','2222')
union all
select 3, array()
union all
select 4, array('5671','9765')
)
select * from mytable
where concat('|',concat_ws('|',`values`),'|') rlike '\\|121'
Result:
id values
1 ["8001","12100"]
2 ["12134","9999","2222"]
Note: Pipe |
in regex needs to be escaped with double backslash.
How to retrieve Facebook-like people counter with SQL Server?
Append COUNT(*) - 3
:
DECLARE @count int = (SELECT COUNT(*) - 3
FROM problem
LEFT JOIN person
ON problem.problemId = person.problemId
INNER JOIN
problem_person
ON problem_person.personId = person.Id)
select problem.*,
(
STUFF
(
(
SELECT TOP(3)', ' + person.name
FROM
problem_person
LEFT JOIN person ON problem_person.personId = person.Id
WHERE
problem_person.problemId = problem.Id
order by person.name
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)'), 1, 1, ''
) + CASE WHEN @count > 0 THEN N' and ' + CAST(@count as NVARCHAR(20)) + N' more faced the problem' ELSE N'' END
) as peopleWhoFaced from problem
Related Topics
SQL Server Management Studio - How to Change a Field Type Without Dropping Table
Using Table Variable with Sp_Executesql
How to Use a SQL Update Statement to Add 1 Year to a Datetime Column
Difference Between Varchar(500) VS Varchar(Max) in SQL Server
Count Number of Null Values in Each Column in SQL
Combining Union All and Order by in Firebird
Oracle Table Column Name with Space
MySQL - Creating Rows VS. Columns Performance
How to Have the Table Name as "Option" in MySQL
Anyway for Ado to Read Updated Data from a Read-Only Excel File Before Save? (Vba)
Deleting Duplicates Rows from Redshift
SQL Like Operator to Get the Numbers Only
Casting Scientific Notation (From Varchar -> Numeric) in a View
SQL Server 2008 Insert with While Loop
Database Normalization - Who's Right
Invalid Column Name on SQL Server Update After Column Create
How to Set a Size Limit for an "Int" Datatype in Postgresql 9.5