Redshift - Filter multiple Not in condition - amazon-redshift

I am trying to build a query that filters out any email that has gmail or yahoo in the name. I tried the below:
select email from users where email not like ('#gmail.com','#yahoo.com')
I get an error
ERROR - operator does not exist: character varying
I am using Redshift DB. Thanks..

where email not like '%#gmail.com'
and email not like '%#yahoo.com'
there is no combination of a list with like, it works only for exact matches (in), and don't forget the wildcard (%)
if the list is larger there is another solution with a given answer (can look it up here if so)

Related

Postgres/Flyway: How can I wrap long constant strings in sql file?

I want to line wrap the SQL in my flyway migration file, the working version looks like:
comment on table account is
'Multiple users may be associated with the same account (think multiple login methods, like gmail + facebook, etc.) ';
If I use IDEA and hit enter within the string it generates this:
comment on table account is
'Multiple users may be associated with the same account (think multiple' ||
' login methods, like gmail + facebook, etc.) ';
But then running the migrate operation gives the error PSQLException: ERROR: syntax error at or near "||".
Versions: Flyway 4.2, Postgres 10
It's perfectly fine to split a string across lines in SQL (without any concatenation operator):
comment on table account is
'Multiple users may be associated with the
same account (think multiple login methods,
like gmail + facebook, etc.)';
Alternative answer for wrapping the source code only, rather than the contents of the string :
comment on table account is
'Multiple users may be associated with the same account (think multiple'
' login methods, like gmail + facebook, etc.)';

Laravel 5.1 Reset Password Function; user's email is in a different table

I have a question regarding Laravel's Reset Password function. I have thoroughly searched for a possible solution and could not find one. Moreover, I tried to scrutinize the code and manually implement it, but failed miserably because of the nesting. (I'm new to Laravel).
According to Laravel's documentation, the user's email must be in the table user in order to work and the error code confirms it.
*Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: select * from user where email = usermail#provider.com limit 1*
However, we do have the scenario that an user might have multiple email addresses, hence stored in a different table called user_email.
Does anybody have experience with this scenario and could take the time to enlighten me on this?
You have two Options:
Write your own password recovery system.
Let the user choose a primary e-mail and make a column on the users table which represents the primary e-mail adresse.

GitHub API search query for non-null parameters?

I'm trying to search for the top GitHub users by # of non-forked repos, that have a public email address. When using the /search/users endpoint, it seems you must pass a query (q= parameter) and when I tried the following, it returned one result:
https://api.github.com/search/users?q=%40&in:email&sort=repositories&order=desc&type=user
I know my syntax is off by the documentation (here and here) is not very helpful when constructing the URI.
Is there a way to specify that I want to select those users with the most non-forked repos and with non-null/empty email fields?
Is there a way to specify that I want to select those users with the most non-forked repos and with non-null/empty email fields?
No, not possible currently using the Search API.

SugarCRM related Field

I have sugarCRM 6.5.20 OnDemand. I am in the Studio. I have a 1:1 relationship from Leads to Leads. I am trying to get the Primary Email address of the related Lead and display it in a calculated field.
It seems like the calculated field formula should look like:
related($emails,"email1")
When I do that I get the following error:
Invalid formula: related: Unknown Field : email1
The dropdown list doesn't list the email at all. How can I get the email? All of my web searches have proven ineffective.
Update:
I am willing to make the calculated field be the primary email address of the current lead. To do that I found 2 variables named $email_addresses and $email_addresses_primary and $emails. There is also a function called valueAt.
I tried to use valueAt(1,$emails) and valueAt(1,$email_addresses)
The validator accepted the syntax but the value was always empty.
Can I make a calculated field off of the leads primary email?
You won't get the Email field for the Studio's formula calculation. Email field is stored in a separate table and not in the module's table. It is just put in the Layout along with the other fields of the module, but it is not the same as other fields. All the Email Addresses irrespective of the modules are stored together in the email_addresses table and are related to respective module records in the email_addr_bean_rel.

Validating SSN,Email and Phone number in Postgres

Could anyone help me on how to perform validation on SSN, Email, phone through a stored procedure in Postgresql?
Thanks.
A stored procedure doesn't look like the right solution. Use a domain with a check constraint using pattern matching. There is an example on the CREATE DOMAIN reference page. For email address checking, consider http://wiki.postgresql.org/wiki/Email_address_parsing.