Try something like this:
library(stringr)
library(dplyr)
library(tidyr)
text <- readLines("file.txt")
dataFrame <- data.frame(column-name = str_match(txt, "Select\\s+(.*?)\\s+from")[,2],
table-name = str_match(txt, "from\\s+(.*?)\\s+where")[,2])
dataFrame <- dataFrame %>%
separate_rows(column-name, sep = ",") %>%
separate_rows(table-name, sep = ",") %>%
filter(word(trimws(column-name), 1, sep = "\\.") == word(trimws(table-name), -1)) %>%
mutate(column-name = word(trimws(column-name), -1, sep = "\\."),
table-name = word(trimws(table-name), 1))