Is there a way to single out data within an SQL column? - sql

So I'm working with an old joomla site and trying to export only useful data, and I found a pretty hacky way of accomplishing what I wanted to do.
So for the column I want to get to, images, even though there's been no useful information input into it, joomla automatically populates it with the following:
{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
I Ideally only want to search for fields where the value for image_fulltext is not empty, and only get the value of the field.
My original idea was this hacky snippet just to find the relevant rows at least.
SELECT id, images FROM `JOOMLAPREFIX_content` WHERE images !='{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}'
This gets the me the relevant rows, but it also gets me more information than I want. (The first suggested solution, while a much less "hackey" query, gets me the same result, as you can see in the SQL snippet.)
Id Images
7 {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"images\/featuredimage1832014.jpg","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
Is there a way to target only the value of image_fulltext, in the case of this row: "images/featuredimage1832014.jpg"?
SQL Fiddle

Try this:
SELECT id, images FROM `JOOMLAPREFIX_content` WHERE images NOT LIKE '%"image_fulltext":""%'

Related

So, RStudio 2022.12.0 Build 353 does not show the last rows of the tibble in the R-document file. Anyone knows the solution, please

so, I have this data in the tibble displayed in the R-document. The first rows are shown fine the image of the first rows in the R-document, but the last are not shown (its just empty tibble, which has the data, but these cannot be seen cause I like can copy some of them) the image of the last rows in the R-document. The same thing is happening if the data were in the dataframe. Does anyone know how to overcome this issue, so in the R-document, one can see all the data clearly? Thanks in advance.
I can look at the data with View(), no problem, but it is not the way I want the reader to see the data as it's like a different window and not in the R-Document. I expect these last rows be either non-present or show the actual data.
ok, never mind. I just found a temporary and the best-at-the-moment solution, which is to use the function print.data.frame(). Though, it has not a good view like when you do it using the print() function, but it prints all the data (first rows) (last rows).

PowerApps filter returning incomplete data record...?

I have an Azure SQL database, and my records inside table Spiderfood_RITMData in that database includes 13 different fields. Lots of stuff. I have confirmed in SQL-SMS that the records have data in each field.
There are way more items in the database than PowerApps can see using LOOKUP (1600-9000 records or more). However, I know FOR A FACT that there is only ONE record that has any given value in the NUMBER column. It's not a primary key, but it is unique in the table.
In PowerApps, I am trying to pull that field so that I can eventually parse out the individual items.
So, the commands I'm trying are:
ClearCollect(MLE_test1, Filter('Spiderfood_RITMData', "RITM2170467" in Number));
ClearCollect(MLE_test2, Search('Spiderfood_RITMData',"RITM2170467", "Number"));
However, the Collection results for MLE_test1 and MLE_test2 both are empty EXCEPT for the value of NUMBER. Say what?!
I'm trying to use the examples posted on https://learn.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup but I am honestly getting baffled by this.
How should I be formatting this call such that I can pull the whole record?
Big picture explanation: I need to do a lot of data LOOKUPS into my table Spiderfood_RITMData table, but it has way more than 2000 rows, and PowerApps will not perform the Lookup correctly. So my presumably smart idea is to create a MUCH SMALLER "version" of Spiderfood_RITMData as a local collection, using a more delegateable function (such as FILTER or IN). If I filter by all records containing the values of NUMBER, then I go from, say a 10,000-record SQL table to a 10-record Collection. And I can do LOOKUPS against that collection for the rest of the function (uh, I think -- I'm still trying to experiment accordingly). Please let me know if this is crazy or not.
LookUp is just used to get one record, instead try this:
ClearCollect(MLE_test1, Filter('Spiderfood_RITMData', "RITM2170467" = Number));
This gets a collection with all the items where Number is = to "RITM2170467"
Collections are limited to only 2000 records in each collections.
I had same issue. Go to App settings. Under Upcoming Features make sure Explicit column selection is turned off. Hope this does it for you.

Retrieve results from a batch of SQL queries in Pentaho or Postgres?

I'm still relatively new to SQL and Pentaho.
I've pulled a table with two different IDs and need to run a query for each specific instance.
For example,
SELECT *
FROM Table
WHERE RecordA = 'value in column A'
AND RecordB = 'value in column B'
I need the results back, either appended to new columns in the original table or part of their own text file output.
I was initially looking at using a formula for this inside of Pentaho, but couldn't quite figure it out. Since I have the query written I threw it into Excel and got the concatenated results (so a string of 350 or so queries that I need to run). I'm just not sure how to accomplish this - I tried the Execute SQL Script inside of Pentaho but it doesn't seem to do output?
Any direction would be useful. I've searched a little but have come up short so far, possibly because I am still pretty new to this platform.
You can accomplish this behavior in a lot of ways, with a "Database Lookup" step for example, but I usually do that in a quite easy way and here is a example for your tests, I hope it helps.
The idea here is to have two Table input steps, the first one will fetch the IDs we want to look at. For example you may use a SQL query similar to note on the left. The result will be a 1 column stream of rows.
Next we have a Table Input that reads the rows received and executes it's query for each row. I'll add a screenshot with the options that I selected.
What it does is replace a placeholder '?' with the data that is received. If you need two columns use two '?' but remember that it will replace the first one with the first column and the second one with the second column
And you are good to go. Test it a couple of times and good luck.
And the config for the second table input.

Filter certain SQL data formatted in one column into a new column

Before I begin I found this to be most relevant with the research I have done.
How to split the data from one column into separate columns using the contents of another column in SQL
Attached are pictures of my progress so far. How can I display this information such as it is shown in the excel file without disrupting the GROUP BY filter in my Query?
It's a Fishbowl Database, newest version. I am running the queries through Flamerobin which you see in the picture. Trying to organize the query to display correctly so I can format it into 'iReports' and export it into an excel spreadsheet like the one shown. Maybe there is some part of this that would better be done in excel?
Notice the numbers for Qty are different, that's ok right now.
My reputation is too low to post pictures I am sorry. Here are the two JPGs in my Dropbox. I really appreciate the help.
https://www.dropbox.com/sh/r2rw5r2awsyvzs9/AAAXXg27CMPOYtZFqPX3Dx6la?dl=0

Searching in PL/SQL /Oracle Forms

This is with respect to search of a text in a table
Table_Name:
Details
Columns:
Fname,Mname,Lname,NName
This table contains nearly one lakh records
We are using Oracle forms for some querying option
The user input one name the form searches the table for the name and based on the name either(Fname/Mname/Lname/NName) in which column its is present further actions are proceeeded.
The search is taking a long time since we have huge amount of data present in the table.
I tried with Functional indexes for the table but t did not work its also taking more time
Later i tried with something like this
concatenated all the names into one name and put it into a cursor.
Using the cursor output i tried with Instring but it is hanging
I also tried with searching for building a dynamic cursor but it did not work.
My database is Oracle
Can u help me to out to find an effective solution or please help me if i have missed something.
Thanks
First of all, 1 lakh (100,000) records is not in itself a large table.
The problem I can see is the query appears to be doing an OR against the Fname/Mname/Lname/NName columns.
This means the query will be doing at least one full-table scan to obtain the results.
You may wish to use debug to obtain the query it is firing against the database and attempt to tune this at the SQL prompt using auto trace.
You may need to clarify if the search is also doing something like a LIKE against these columns rather than an EQUALS. As a LIKE will impact the query further and affect indexes.
Certainly the use of INSTR will disable indexes on your searched column.
It is not clear if what your block is based on ie. table, view, query, procedure
You may want to try using the hint on the block properties of the form FIRST_ROWS.