使用电子邮件地址查询MySQL数据库中的用户名(Query MySQL database for user names with their email addresses)
我正在寻找一种方法来查询我的所有用户(很简单),但我需要让特定用户回到结果中。 我将尝试解释下面我能做的最好但总之,我想使用电子邮件地址列表作为参考,以拉动所有匹配这些电子邮件地址的用户。
简要概述
我有一个wordpress网站,我从中运行事件。 当人们注册活动时,会为他们创建一个帐户。 还有另一个与会者表,将这些用户配置文件链接到他们的注册。
就像现在一样,我需要获得一个特定于一个活动组织者的人员列表。 我认为最好的方法是使用来自与会者信息的电子邮件地址,并在我的wp_users表中查询用户名。
SELECT display_name FROM `mydatabase`.`wp_users` WHERE `user_email` LIKE 'myemail@email.com' OR 'mysecondemail@email.com' OR 'mythirdemail@email.com';
我删除了真实的电子邮件并更改了数据库名称。
我想要实现的是一个查询,它将通过我的用户列表运行,比较我提供给表中用户的电子邮件地址,并返回任何匹配的用户。
就像现在一样,它返回它找到并停止的第一个结果。
我已经准备好了电子邮件列表,但我正在努力让这个工作。
I'm looking for a way to query all of my users (simple enough) but i need to get specific users back in the results. I'll try explain the best i can below but in short i want to use a list of email addresses as a reference to pull all users matching those email addresses.
Brief overview
I have a wordpress website which i run events from. When people sign up for the events an account is created for them. there is also another table for attendees which links these user profiles to their registrations.
As it is right now i need to get a list of people specific to one event organiser. I thought the best way to do this would be to use their email address from the attendee info and query my wp_users table for the user names.
SELECT display_name FROM `mydatabase`.`wp_users` WHERE `user_email` LIKE 'myemail@email.com' OR 'mysecondemail@email.com' OR 'mythirdemail@email.com';
I've removed the real email and changed the database name.
What i am trying to achieve is a query that will run through my list of users comparing their email address that i provide to the users in the table and return any of them that match.
As it is right now it returns the first result it finds and stops.
I've got the list of emails ready to go but i am struggling to get this to work.
原文:https://stackoverflow.com/questions/43516482
最满意答案
显然我解决了它。 在for的内部有代码用
NSMutableAttributedString
的图像替换子字符串。 此外,我决定在类似(但不同)的问题中对前一个答案进行反思NSMutableAttributedString *formattedText = myString.mutableAttributedString; // Look for image NSString *regEx = @"([a-z])+(?:([0-9])+){0,1}.png"; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regEx options:NSRegularExpressionCaseInsensitive error:&error]; if(error != nil){ NSLog(@"Error: %@",error); } else{ NSArray *matches = [regex matchesInString:myString options:kNilOptions range:NSMakeRange(0, myString.length)]; for (NSTextCheckingResult *result in [matches reverseObjectEnumerator]) { NSString *insideString = [myString substringWithRange:[result rangeAtIndex:0]]; UIImage *image = [UIImage imageNamed:insideString]; NSTextAttachment *imageAttachment = [NSTextAttachment new]; imageAttachment.image = image; NSAttributedString *replacementForTemplate = [NSAttributedString attributedStringWithAttachment:imageAttachment]; [formattedText replaceCharactersInRange:result.range withAttributedString:replacementForTemplate]; NSLog(@"found! -> %@", insideString); } }
相反,
mutableAttributedString
属性属于NSString类别。 这是它的代码- (NSMutableAttributedString *)mutableAttributedString { return [[NSMutableAttributedString alloc] initWithString:self]; }
Apparently I resolved it. Inside the for there is the code to replace a substring with an image in the
NSMutableAttributedString
. Also I decided to put a reversedfor
in inspiration to a previous answer in a question similar (but different) like thisNSMutableAttributedString *formattedText = myString.mutableAttributedString; // Look for image NSString *regEx = @"([a-z])+(?:([0-9])+){0,1}.png"; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regEx options:NSRegularExpressionCaseInsensitive error:&error]; if(error != nil){ NSLog(@"Error: %@",error); } else{ NSArray *matches = [regex matchesInString:myString options:kNilOptions range:NSMakeRange(0, myString.length)]; for (NSTextCheckingResult *result in [matches reverseObjectEnumerator]) { NSString *insideString = [myString substringWithRange:[result rangeAtIndex:0]]; UIImage *image = [UIImage imageNamed:insideString]; NSTextAttachment *imageAttachment = [NSTextAttachment new]; imageAttachment.image = image; NSAttributedString *replacementForTemplate = [NSAttributedString attributedStringWithAttachment:imageAttachment]; [formattedText replaceCharactersInRange:result.range withAttributedString:replacementForTemplate]; NSLog(@"found! -> %@", insideString); } }
Instead the
mutableAttributedString
property belongs to a NSString Category. This is the code of it- (NSMutableAttributedString *)mutableAttributedString { return [[NSMutableAttributedString alloc] initWithString:self]; }
相关问答
更多-
我不知道Dreamweaver,但您可以尝试明确匹配行开头和结尾: ^{"id":([^,]*?),(.*?)((type":([^,]*?),(.*?)quality":([^,]*?))|((.*?)quality":([^,]*?),type":([^,]*?))),(.*?)name":"([^,]*?)"(.*?)},$ I don't know Dreamweaver but you can try to match line beginning and end explicitly: ^{" ...
-
那是因为{和}是正则表达式语法的一部分。 您可以使用斜杠( \ )来转义它们。 这样的事情可能有用: \\theta\^\{?\\top\}?\s*\{?x_\{?2\}?\s*\+\s*x_\{?1\}? 让我们分解吧。 \\theta\^将匹配字符串\theta 。 请注意,我们必须转义\t和^因为\t是一个选项卡,而^是正则表达式语法的一部分。 \{? 和\}? 将匹配{或}一次或根本不匹配。 我们必须再次摆脱括号。 问号( ? )表示该字符可以出现0或1次。 \\top - 再次,我们必须逃脱制表 ...
-
注意:Xcode 6中的行为已更改。\ 123语法已替换为$ 123。 还要警告,现在可以在reg exps中匹配换行符,因此请务必在Replace-Alling之前进行删除 向方法添加一个附加参数: 取代 [* setFoo:*] 同 [* setFoo:* bar:value] 你做 (setFoo:)(.*)(\]) $1$2 bar:value] (分别是搜索字符串和替换字符串)。 或者,如果在Xcode 5或更旧版本 (setFoo:)(.*)(\]) \1\2 bar:value] (以 ...
-
NSString *string = @"123 &1245; Ross Test 12"; NSError *error = nil; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"&[^;]*;" options:NSRegularExpressionCaseInsensitive error:&error]; NSString *modifiedString = [regex strin ...
-
您可以通过两个步骤快速完成此操作: 使用公式制作第5列(假设数据从A列和第2行开始): =if(C2="t-shirt", D2-50, if(c2="pants", 38.00, D2))并复制所有行 将value-paste->值复制并粘贴到价格列中。 You could do this quickly with two steps: Make a 5th column with the formula (assuming data starts in Column A and second row): ...
-
你可以使用正则表达式组。 根据你上面的示例输入/输出,下面的工作适合我。 找什么: :(\w+@.*?):(.*?)<(\w+@.*?)>: 用。。。来代替: :\1:\2<\1>: You can use regex groups. Based on your sample input/output above, the below worked for me. Find what: :(\w+@.*?):(.*?)<(\w+@.*?)>: Replace with: :\1:\2<\1>:
-
来自docs : 可选的就地过滤:如果将关键字参数inplace = 1传递给fileinput.input()或FileInput构造函数,则将文件移动到备份文件,并将标准输出定向到输入文件 (如果是文件的与备份文件相同的名称已经存在,它将被静默替换)。 你需要做的只是在循环的每一步中打印line 。 此外,您需要在没有其他换行符的情况下打印行,因此您可以使用sys模块中的sys.stdout.write 。 结果是: import fileinput import re import sys ... ...
-
我不熟悉Eclipse的正则表达式语言,但我想你想要这样: "<\?[^p]" 区别在于: [^p]是指除p之外的任何字符 ^[p]表示后面跟着一个新行的开头。 但是您应该查看Eclipse手册以找出Eclipse使用的确切正则表达式语法。 I'm not familiar with Eclipse's regular expression language but I'd imagine you want this: "<\?[^p]" The difference is: [^p] means an ...
-
显然我解决了它。 在for的内部有代码用NSMutableAttributedString的图像替换子字符串。 此外,我决定在类似(但不同)的问题中对前一个答案进行反思 NSMutableAttributedString *formattedText = myString.mutableAttributedString; // Look for image NSString *regEx = @"([a-z])+(?:([0-9])+){0,1}.png"; NSError *error = nil; N ...
-
我得到了这个问题的答案。 这里computedString包含的值为“{3} * 0.42 /({2} / 100)^ 2”。 - (NSString *)autoCalculationField: (NSString *)computedString { NSString *computedStringFormula = [NSString stringWithFormat:@"%@",computedString]; NSRegularExpression *regex = [NSReg ...