alasql


Alasql select in arrary of array with uknown index


suppose I have this structure data
data =[
{
"id":1,
"link":[
{
"id":3
},
{
"id":1
},
{
"id":2
}
]
},
{
"id":2,
"link":[
{
"id":30
},
{
"id":11
},
{
"id":22
}
]
}
]
I want see if my structure have a link with id=11
"SELECT * FROM ? WHERE link->[1]->id=11"
work but because I already know that I must check in index 1. How can I check in all indexes?
The SEARCH function would be good if it was fully implemented
alasql('SEARCH / link / WHERE(id=11) .. / .. FROM ?',[data]);
But the parrent .. selector is not implemented yet.
I suggest doing a (not totally elegant) user defined function:
alasql.fn.deepSearch = function(id, obj){
return alasql("SEARCH / link / WHERE(id=?) FROM ?", [id, [obj]]).length
}
alasql('SELECT * FROM ? WHERE deepSearch(11,_)',[data]);
The correct code is
alasql('SEARCH / AS #a link / WHERE(id=11) #a FROM ?',[data]);
Here AS #a saves current element into the variable #a, and the second #a retrieves it.

Related Links

AlaSQL can you use DISTINCT with SEARCH
Can one use CSV as an in-memory database with alasql?
Export the data to excel & formatting that as requirements
determining what array elements were removed
return alasql informational results
INSERT/UPDATE existing object?
How to insert data in google spreadsheet with tabletop?
How can I export to excel using alaql to multiple sheets AND have different display options for each sheet
AlaSQL saved database location
running two queries and then joining the results alasql promise notation
parent and child key in alasql rollup functions
Alasql select in arrary of array with uknown index
Alasql Best Practices
Alasql - Having columns with sub-columns
AlaSQL: Getting where opperands
ALASQL: How to reference the JSON object it self (to call a function on it)?

Categories

HOME
asterisk
url
sql-server-2014
pyspark
service
formatting
grpc
window.open
liquibase
dynamic
gaussian
hex
stdout
x509certificate
query-string
coordinates
snmp
swap
android-webview
obd-ii
software-collections
soap-client
dynamics-crm-2011
osrm
dompdf
facebook-marketing-api
accordion
glibc
url-parameters
webgl-earth
ajaxcontroltoolkit
typedef
wai-aria
advertising
ps
apdu
multiple-inheritance
angular2-changedetection
pushpad
federated
jbossfuse
intermec
overflow
mplab
availability
bootcamp
tunnel
wunderground
azure-vm-scale-set
iterm2
motion
ssdp
definition
web-technologies
head
risc
chrome-custom-tabs
spring-ide
lucee
noise
pyautogui
breadcrumbs
turbolinks
zsh-completion
mongodb-3.3
access-violation
networkstream
hoare-logic
boost-propertytree
phpdesigner
ooad
gulp-cdnizer
dnvm
vspackage
glog
grails-3.0.9
screen-lock
bungeecord
google-experiments
qf-test
conditional-comments
lwuit
nspopupbutton
banana-pi
acrofields
facebook-java-api
nomachine
adabas
grunt-contrib-imagemin
select2-rails
wordbreaker
magicsuggest
simplemembership
auctex
blackberry-eclipse-plugin
flatten
nsscrollview
erlide
jmesa
datejs
sipdroid
object-tag
n2
lgpl
chars
google-local-search
dojox.gfx
disk-based
tracd

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile