Database Link id Line Print - database

How can I print the ids in the table with this link as text, for example 1204,1205,1206,1207,1237 like this
Link: https://image.test.com/file/img/
image:
https://i.stack.imgur.com/5oQjK.jpg

Related

SQL replace - find word and replace it

i have one task.
I have a table which contain some columns. One column is a TEXT - string, which contain some sentences or some html code with neccesary text. I need find a text which contain some word f.e. 'TEAM' and replace it to 'AMOUNT'.
I tried something but it change all text in column only to AMOUNT, My goal is 'this is a TEAM' replace to 'this is a AMOUNT'. (The word TEAM i have in 250 documents and i need change only this one word in all documents in TEXT column)
Update TABLE
SET Text = replace('TEAM', 'TEAM', 'AMOUNT')
Where text like '%TEAM%'
you need the text column in replace
Update TABLE
SET Text = replace(text, 'TEAM', 'AMOUNT')
Where text like '%TEAM%'
seems you are not using mysql but sql.serve and you have ntext
so you could try using a cast
Update TABLE
SET Text = replace(cast text as nvarchar(4000), 'TEAM', 'AMOUNT')
Where text like '%TEAM%'

Split function in hive does not seem to be working on caret symbol

The data in my column user_likes is as follows: anime^sitcom^scifi. I am trying to get the first item in the user likes column as output.
My query is as follows:
SELECT split(user_likes,"\\^")[0] as likes from user_data_consolidated
but the output of this query is:
anime^sitcom^scifi
SELECT substr(user_likes,1,((locate('^',user_likes )-1)))
as likes from user_data_consolidated

Full text search syntax error

I created a full text search with a catalog and index and the contains query works fine when I run a query with one word like below.
SELECT Name
FROM dbo.Gifts
WHERE CONTAINS(Name, 'gift')
it returns 'test gift'
I have only one row in the table and the data in the Name column looks like this: 'test gift'
but when I run the conaints query with this statement:
SELECT Name
FROM dbo.Gifts
WHERE CONTAINS(Name, 'test gift')
It throws an error saying: Syntax error near 'gift' in the full-text search condition 'test gift'.
I thought contains could query phrases and multiple words that match and sound alike?
You need double quotes to manage that space, keeping in mind that you are searching for the entire string, and not the words of the string. The following query would find "test gift" but not "gift test"
SELECT Name
FROM dbo.Gifts
WHERE CONTAINS(Name, '"test gift"')
or, if you want to search words individually, it would be
SELECT Name
FROM dbo.Gifts
WHERE CONTAINS(Name, '"test" AND "gift"')
this second one should get you a field with "gift test" as well as "test gift"

How to fetch comments from a Drupal article in PHP?

How to fetch comments from a Drupal article in PHP ? The output is preferably in XML / RSS .
http://drupal.org/project/commentrss --> if you want to use module
or you want to do it programmatically ?
UPDATE:
if you have content type "article".. then you can do the following
1- get all the nid from table {node} where type = "article"
2- get all the comment id && comment title cid && subject from table {comment} where nid = (your articles nid)
3- the last thing is to get the comment body comment_body_value from table {field_data_comment_body} where comment id is one of the comments we get in step 2
SUMMARY :
1- comments with out body are stored in table {comment}
2- the body of the comments are stored in table {field_data_comment_body} with field name comment_body_value
hop that will help u

How to use FULL-TEXT SEARCH in H2 Database?

Consider the following example
CREATE ALIAS IF NOT EXISTS FT_INIT FOR "org.h2.fulltext.FullText.init";
CALL FT_INIT();
DROP TABLE IF EXISTS TEST;
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR);
INSERT INTO TEST VALUES(1, 'Hello World');
CALL FT_CREATE_INDEX('PUBLIC', 'TEST', NULL);
and i have executed the following query
SELECT * FROM FT_SEARCH('Hello', 0, 0);
But this query is returning "PUBLIC"."TEST" WHERE "ID"=1 .
Do i have to again execute this "PUBLIC"."TEST" WHERE "ID"=1 to get the record containing 'Hello' word ?
What is the query to search all records with 'ell' word in them from the FT_Search. such as like %ell% in H2 Native Full-Text Search
Yes, each row in a query using FT_SEARCH represents a schema-table-row where one of the key words was found. The search is case insensitive, and the text parameter to FT_SEARCH may include more than one word. For example,
DELETE FROM TEST;
INSERT INTO TEST VALUES(1, 'Hello World');
INSERT INTO TEST VALUES(2, 'Goodbye World');
INSERT INTO TEST VALUES(3, 'Hello Goodbye');
CALL FT_REINDEX();
SELECT * FROM FT_SEARCH('hello goodbye', 0, 0);
returns only row three:
QUERY SCORE
"PUBLIC"."TEST" WHERE "ID"=3 1.0
Also note that FT_SEARCH_DATA may be used to retrieve the data itself. For example,
SELECT T.* FROM FT_SEARCH_DATA('hello', 0, 0) FT, TEST T
WHERE FT.TABLE='TEST' AND T.ID=FT.KEYS[0];
returns both rows containing the keyword:
ID NAME
1 Hello World
3 Hello Goodbye
Apache Lucene supports wildcard searches, although leading wildcards (e.g. *ell) tend to be expensive.
Do i have to again execute this "PUBLIC"."TEST" WHERE "ID"=1 to get the record containing 'Hello' word ?
Yes, except if you use a join as described by trashgod. The reason is: usually rows are much larger than just two words. For example, a row contains a CLOB with a document. If the result of the fulltext search would contain the data, then fulltext search would be much slower.
What is the query to search all records with 'ell' word in them from the FT_Search. such as like %ell% in H2 Native Full-Text Search
The native fulltext search can't do that directly. The reason is: fulltext search only indexes whole words. (By the way: does Google support searches if you only know a part of a word? Apache Lucene does support it) Actually, for H2, there would be a way: first, search the words table (FT.WORDS) for matches, and then use a regular search.

Resources