Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 08-09-2016 07:14 PM
Hello,
I have a phoenix view on an existing hbase table. I don't find in the documentation how to select every lines of a table where the column "name" match with a specific regex or function on string like contain, start with, etc. For example in "traditional sql": select name,phone from table1 where like "%ab%; or every ligne with a rowkey that start with "blabla".
Thanks in advance to point me how to do it easily (I hope that's not needed to use UDF...)
Michel
Created 08-09-2016 07:16 PM
See http://phoenix.apache.org/language/index.html#condition. Your "traditional sql" approach works with Apache Phoenix.
> create table foo(s varchar, pk integer not null primary key);
> upsert into foo values('abcd_bar', 1);
> upsert into foo values('dcba_bar', 2);
> select * from foo where s like 'abcd%';This will return
+-----------+-----+ | S | PK | +-----------+-----+ | abcd_bar | 1 | +-----------+-----+
Created 08-09-2016 07:16 PM
See http://phoenix.apache.org/language/index.html#condition. Your "traditional sql" approach works with Apache Phoenix.
> create table foo(s varchar, pk integer not null primary key);
> upsert into foo values('abcd_bar', 1);
> upsert into foo values('dcba_bar', 2);
> select * from foo where s like 'abcd%';This will return
+-----------+-----+ | S | PK | +-----------+-----+ | abcd_bar | 1 | +-----------+-----+
Created 08-09-2016 07:31 PM
Ok super thanks, I didn't try because it was not refer in the documentation that the function like work. 🙂
Created 08-09-2016 07:21 PM
@Michel Sumbul you may find all functions here https://phoenix.apache.org/language/functions.html and of course you may use 'like' keyword, so it will be as a regular sql query:
select name, phone from table1 where name like '%Smith%'
Created 02-22-2017 06:15 AM
Now if table has records like
And i want to search only 1234_bar(starting with digits), then how should i write the queries in Phoenix.
,If Table records are like
And now if i want to search only 1234_bar then how should i write Select query ?
Created 02-22-2017 03:36 PM
Do not piggy-back on others' questions which have already been answered, please. Ask your own question.