narcis VIP
Total posts: 138
14 May 2015 14:25

Hello,

I'd like create SQL Query to allow user to select an ID of any Cobalt record of specific Sections. So i set this, but does not work :

SELECT id FROM #__js_res_record WHERE section_id = [1,3,5]

What does External database mean ? Actually, i did not complete details related to External database, since Cobalt is running on my site.

Help please.

Last Modified: 25 May 2015


klox7 VIP
Total posts: 914
14 May 2015 20:47

This works, you could also read this Click here to link...

SELECT r.id AS text 
FROM #__js_res_record AS r
WHERE r.id IN (SELECT id from #__js_res_record WHERE section_id IN(1,3,5))

Regards


narcis VIP
Total posts: 138
15 May 2015 09:27

Thanks klox7.


narcis VIP
Total posts: 138
15 May 2015 15:19

OK, i want to report a strange behavior : when i select value in frontend, this value does not appear in record, that Select field is just empty. If i make this field required, while submitting, i get message saying that the field is required even if i select a value there.

i forget something ?


narcis VIP
Total posts: 138
19 May 2015 10:20

Someone had the same issue ?


Sergey
Total posts: 13,748
19 May 2015 16:24

klox7 This works, you could also read this

It can be simplier :)

SELECT r.id AS text 
FROM #__js_res_record AS r
WHERE r.section_id IN(1,3,5)

narcis OK, i want to report a strange behavior : when i select value in frontend, this value does not appear in record, that Select field is just empty. If i make this field required, while submitting, i get message saying that the field is required even if i select a value there.

i forget something ?

Are you trying to use SQL source in select field? What is your final query?


narcis VIP
Total posts: 138
20 May 2015 15:31

I try to use sql source in multiple select field. I want user attach a record of another in his own record (like parent/child feature). I plan to buy subcription in 2 months; just want to assess some project now :+).


Sergey
Total posts: 13,748
22 May 2015 04:14

This is the query

SELECT r.id, r.title AS text 
  FROM #__js_res_record AS r
 WHERE r.section_id IN(1,3,5)
   AND r.user_id = [USER_ID]

No in post process URL insert and enable it

index.php?option=com_cobalt&view=record&id=[ID]&Itemid=140

Change ItemID to correct one of course.

Now you will chose articles and get their title displaied as links to those articles.


narcis VIP
Total posts: 138
22 May 2015 10:38

Thanks Sergey, this helps me.

Just one more question, actually i want to force user to attach the record of another user. So my question is : is there any sql query to select records of any user except those of current user ?


pepperstreet VIP
Total posts: 3,837
23 May 2015 15:47

narcis select records of any user except those of current user ?

Change the last line of the SQL to:

AND r.user_id != [USER_ID]

Newer MySQL versions can use the following operator syntax, too:

AND r.user_id <> [USER_ID]

Both mean NOT EQUAL TO.


narcis VIP
Total posts: 138
25 May 2015 12:44

Great! Thank you pepperstreet.

Powered by Cobalt